diff --git a/Cargo.toml b/Cargo.toml index fca85e6..8ea42f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,8 @@ members = [ 'foundation', 'server', - 'client', - 'serverctl', - 'example_plugin' + 'protocol' ] + +[workspace.dependencies] +protobuf-codegen = "3.4.0" \ No newline at end of file diff --git a/protocol/Cargo.toml b/protocol/Cargo.toml new file mode 100644 index 0000000..4ba7573 --- /dev/null +++ b/protocol/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "protocol" +version = "0.1.0" +authors = ["michael-bailey "] +edition = "2018" + +[lib] + +[dependencies] +chrono = "0.4" +uuid = {version = "1.1.2", features = ["serde", "v4"]} +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +crossbeam = "0.8.0" +crossbeam-channel = "0.5.0" +zeroize = "1.1.0" +tokio = { version = "1.9.0", features = ["full"] } +futures = "0.3.16" +async-trait = "0.1.52" +toml = "0.8.8" +protobuf = "3.4.0" + +[build-dependencies] +protobuf-codegen.workspace = true diff --git a/protocol/build.rs b/protocol/build.rs new file mode 100644 index 0000000..deedf9f --- /dev/null +++ b/protocol/build.rs @@ -0,0 +1,11 @@ +use protobuf_codegen::Codegen; + +// Use this in build.rs +fn main() { + Codegen::new() + .includes(["src/proto"]) + .input("src/proto/messages.proto") + .input("src/proto/network.proto") + .cargo_out_dir("proto") + .run_from_script(); +} diff --git a/protocol/src/lib.rs b/protocol/src/lib.rs new file mode 100644 index 0000000..0aff850 --- /dev/null +++ b/protocol/src/lib.rs @@ -0,0 +1,5 @@ +mod proto; + +pub mod prelude { + pub use super::proto::network::*; +} diff --git a/protocol/src/proto/messages.proto b/protocol/src/proto/messages.proto new file mode 100644 index 0000000..ccaacc8 --- /dev/null +++ b/protocol/src/proto/messages.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; + +message Person { + string name = 1; + int32 id = 2; // Unique ID number for this person. + string email = 3; +} \ No newline at end of file diff --git a/protocol/src/proto/mod.rs b/protocol/src/proto/mod.rs new file mode 100644 index 0000000..a456482 --- /dev/null +++ b/protocol/src/proto/mod.rs @@ -0,0 +1 @@ +include!(concat!(env!("OUT_DIR"), "/proto/mod.rs")); diff --git a/protocol/src/proto/network.proto b/protocol/src/proto/network.proto new file mode 100644 index 0000000..927f8d6 --- /dev/null +++ b/protocol/src/proto/network.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; + +// Network messages from the client. +message NetoworkClientMessage { + oneof message { + GetInfo get_info = 1; + Connect connect = 2; + } +} + +message GetInfo {} + +message Connect { + string username = 1; + string uuid = 2; +} + +// Network messages from the server. +message NetworkServerMessage { + oneof message { + Request request = 1; + } +} + +message Request {} + +message Info { + string server_name = 1; + string owner = 2; +} + +message Connected {}