Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement server-side messages #14

Merged
merged 2 commits into from
Mar 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions server/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ readme = "README.md"
keywords = ["game", "lounge", "server"]
license = "MIT"
version = "0.1.0"
authors = ["nabijaczleweli <[email protected]>"]
authors = ["nabijaczleweli <[email protected]>",
"Cat Plus Plus <[email protected]>"]

[dependencies]
serde = "0.7"
serde_json = "0.7"

[dev-dependencies]
rand = "0.3"
2 changes: 2 additions & 0 deletions server/README
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
1. Install Rust 1.7 (multirust recommended).
2. Run `cargo run`. By default server listens on 127.0.0.1:8080.

If you're not in the authors section in Cargo.toml, add yourself there if you commit any code.
5 changes: 5 additions & 0 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
unused_results,
)]

extern crate serde_json;
extern crate serde;

pub mod message;

use std::env;
use std::vec::Vec;

Expand Down
15 changes: 15 additions & 0 deletions server/src/message/err.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use serde_json;

#[derive(Debug)]
pub enum MessageError {
JsonError(serde_json::Error),
PropertyMissing(String),
ExtraneousProperty(String),
BadType(String),
}

impl From<serde_json::Error> for MessageError {
fn from(sje: serde_json::Error) -> Self {
MessageError::JsonError(sje)
}
}
Loading