migrated tp prost instead of protobuf crate
This commit is contained in:
parent
d93fe70252
commit
4ecf65096e
|
|
@ -6,4 +6,6 @@ members = [
|
|||
]
|
||||
|
||||
[workspace.dependencies]
|
||||
protobuf-codegen = "3.4.0"
|
||||
bytes = "1.6.0"
|
||||
prost = "0.12"
|
||||
prost-build = { version = "0.12" }
|
||||
|
|
@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
|||
use uuid::Uuid;
|
||||
|
||||
/**
|
||||
* #ClientDetails.
|
||||
* # ClientDetails.
|
||||
* This defines the fileds a client would want to send when connecitng
|
||||
* uuid: the unique id of the user.
|
||||
* username: the users user name.
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
use protocol::prelude::*;
|
||||
pub use protocol::prelude::*;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@ tokio = { version = "1.9.0", features = ["full"] }
|
|||
futures = "0.3.16"
|
||||
async-trait = "0.1.52"
|
||||
toml = "0.8.8"
|
||||
protobuf = "3.4.0"
|
||||
|
||||
# prost setup
|
||||
bytes.workspace = true
|
||||
prost.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
protobuf-codegen.workspace = true
|
||||
prost-build.workspace = true
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
use protobuf_codegen::Codegen;
|
||||
use std::io::Result;
|
||||
|
||||
// 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();
|
||||
fn main() -> Result<()> {
|
||||
prost_build::compile_protos(&["src/proto/network.proto"], &["src/proto"])?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
mod proto;
|
||||
|
||||
pub mod prelude {
|
||||
pub use super::proto::network::*;
|
||||
pub use super::proto::*;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
include!(concat!(env!("OUT_DIR"), "/proto/mod.rs"));
|
||||
include!(concat!(env!("OUT_DIR"), "/chatkit.messages.rs"));
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package chatkit.messages;
|
||||
|
||||
// Network messages from the client.
|
||||
message NetoworkClientMessage {
|
||||
message NetworkClientMessage {
|
||||
oneof message {
|
||||
GetInfo get_info = 1;
|
||||
Connect connect = 2;
|
||||
|
|
|
|||
|
|
@ -11,12 +11,31 @@ pub(crate) mod scripting;
|
|||
pub(crate) mod server;
|
||||
|
||||
use server::Server;
|
||||
use tokio::time::{sleep, Duration};
|
||||
use tokio::{
|
||||
net::TcpListener,
|
||||
select,
|
||||
time::{sleep, Duration},
|
||||
};
|
||||
|
||||
/// The main function
|
||||
#[actix::main()]
|
||||
async fn main() {
|
||||
// creating listeners
|
||||
let protobuf_listener = TcpListener::bind("127.0.0.1:6500").await.unwrap();
|
||||
// todo: convert the actix stuff to whatever this is.
|
||||
// let json_listener = TcpListener::bind("127.0.0.1:5601").await.unwrap();
|
||||
|
||||
let _init = Server::create().build();
|
||||
|
||||
select! {
|
||||
Ok((stream, addr)) = protobuf_listener.accept() => {
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
loop {
|
||||
sleep(Duration::from_millis(1000)).await;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue