Made other changes to GRPC implementation to clean it up #23

Merged
michael-bailey merged 30 commits from grpc-manager into master 2024-09-09 16:48:10 +00:00
9 changed files with 40 additions and 17 deletions
Showing only changes of commit 4ecf65096e - Show all commits

View File

@ -6,4 +6,6 @@ members = [
]
[workspace.dependencies]
protobuf-codegen = "3.4.0"
bytes = "1.6.0"
prost = "0.12"
prost-build = { version = "0.12" }

View File

@ -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.

View File

@ -1 +1 @@
use protocol::prelude::*;
pub use protocol::prelude::*;

View File

@ -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

View File

@ -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(())
}

View File

@ -1,5 +1,5 @@
mod proto;
pub mod prelude {
pub use super::proto::network::*;
pub use super::proto::*;
}

View File

@ -1 +1 @@
include!(concat!(env!("OUT_DIR"), "/proto/mod.rs"));
include!(concat!(env!("OUT_DIR"), "/chatkit.messages.rs"));

View File

@ -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;

View File

@ -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;
}