some server work
This commit is contained in:
parent
25179a74f7
commit
b1ef494759
|
@ -24,7 +24,7 @@ message User { string username = 1; }
|
||||||
|
|
||||||
// RPC Messages
|
// RPC Messages
|
||||||
|
|
||||||
message JoinResponse {}
|
message RoomActionResponse {}
|
||||||
|
|
||||||
message RoomAction {
|
message RoomAction {
|
||||||
string roomId = 1;
|
string roomId = 1;
|
||||||
|
|
|
@ -12,7 +12,7 @@ use tower::{Layer, Service};
|
||||||
|
|
||||||
use mraow_common::chat_proto::{
|
use mraow_common::chat_proto::{
|
||||||
chat_server::{Chat, ChatServer},
|
chat_server::{Chat, ChatServer},
|
||||||
ChatMessage, JoinResponse, RoomList, User, UserList,
|
ChatMessage, RoomAction, RoomActionResponse, RoomList, User, UserList,
|
||||||
};
|
};
|
||||||
|
|
||||||
type ResponseStream =
|
type ResponseStream =
|
||||||
|
@ -23,12 +23,12 @@ pub struct ChatImpl {}
|
||||||
|
|
||||||
#[tonic::async_trait]
|
#[tonic::async_trait]
|
||||||
impl Chat for ChatImpl {
|
impl Chat for ChatImpl {
|
||||||
type receiveMsgStream = ResponseStream;
|
type receiveMsgsStream = ResponseStream;
|
||||||
|
|
||||||
async fn join(
|
async fn room_action(
|
||||||
&self,
|
&self,
|
||||||
request: Request<User>,
|
request: Request<RoomAction>,
|
||||||
) -> Result<Response<JoinResponse>, Status> {
|
) -> Result<Response<RoomActionResponse>, Status> {
|
||||||
println!("Join {request:?}");
|
println!("Join {request:?}");
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
@ -89,6 +89,7 @@ impl Chat for ChatImpl {
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
// https://git.mzhang.io/michael/mraow/issues/1
|
||||||
let addr = "[::1]:50051".parse().unwrap();
|
let addr = "[::1]:50051".parse().unwrap();
|
||||||
let greeter = ChatImpl::default();
|
let greeter = ChatImpl::default();
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,13 @@ use tokio::{
|
||||||
task::JoinHandle,
|
task::JoinHandle,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Mux {}
|
#[derive(Clone)]
|
||||||
|
pub struct SharedMux(Mutex<Mux>);
|
||||||
|
|
||||||
|
/// Shared server state
|
||||||
|
pub struct Mux {
|
||||||
|
rooms: HashMap<String, Room>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum RoomMessage {}
|
pub enum RoomMessage {}
|
||||||
|
@ -53,7 +59,9 @@ pub struct CompositeListener {
|
||||||
|
|
||||||
impl CompositeListener {}
|
impl CompositeListener {}
|
||||||
|
|
||||||
fn create_listener() -> (
|
/// Create a "composite" listener that listens to multiple rooms / streams, and
|
||||||
|
/// is able to add more streams in the middle as well
|
||||||
|
pub fn create_listener() -> (
|
||||||
JoinHandle<()>,
|
JoinHandle<()>,
|
||||||
UnboundedSender<CompositeListenerMessage>,
|
UnboundedSender<CompositeListenerMessage>,
|
||||||
UnboundedReceiver<CompositeListenerMessage>,
|
UnboundedReceiver<CompositeListenerMessage>,
|
||||||
|
|
Loading…
Reference in a new issue