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