Fleshing out server
This commit is contained in:
@@ -2,7 +2,7 @@ use std::net::SocketAddr;
|
||||
use futures::future;
|
||||
use futures::future::Ready;
|
||||
use tarpc::context::Context;
|
||||
use crate::types::RealmChat;
|
||||
use crate::types::{Message, RealmChat, Room, SuccessCode, User};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct RealmChatServer(pub SocketAddr);
|
||||
@@ -11,4 +11,32 @@ impl RealmChat for RealmChatServer {
|
||||
fn test(self, context: Context, name: String) -> Ready<String> {
|
||||
future::ready(format!("Hello, {name}!"))
|
||||
}
|
||||
|
||||
fn send_message(self, context: Context, message: Message) -> Ready<SuccessCode> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
async fn get_message_from_guid(self, context: Context, guid: String) -> Message {
|
||||
todo!()
|
||||
}
|
||||
|
||||
async fn get_rooms(self, context: Context) -> Vec<Room> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
async fn get_room(self, context: Context, roomid: String) -> Room {
|
||||
todo!()
|
||||
}
|
||||
|
||||
async fn get_user(self, context: Context, userid: String) -> User {
|
||||
todo!()
|
||||
}
|
||||
|
||||
async fn get_joined_users(self, context: Context) -> Vec<User> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
async fn get_online_users(self, context: Context) -> Vec<User> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,30 @@
|
||||
use tarpc::serde::{Deserialize, Serialize};
|
||||
|
||||
#[tarpc::service]
|
||||
pub trait RealmChat {
|
||||
async fn test(name: String) -> String;
|
||||
async fn send_message(message: Message) -> SuccessCode;
|
||||
|
||||
async fn get_message_from_guid(guid: String) -> Message;
|
||||
async fn get_rooms() -> Vec<Room>;
|
||||
async fn get_room(roomid: String) -> Room;
|
||||
async fn get_user(userid: String) -> User;
|
||||
async fn get_joined_users() -> Vec<User>;
|
||||
async fn get_online_users() -> Vec<User>;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum SuccessCode {
|
||||
Success = 200,
|
||||
Error = 400,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Message {
|
||||
pub guid: String,
|
||||
pub timestamp: u64,
|
||||
pub user: User,
|
||||
pub room: Room,
|
||||
pub text: Option<String>,
|
||||
pub attachments: Option<Vec<Attachment>>,
|
||||
pub reply_to_guid: Option<String>,
|
||||
@@ -13,7 +32,20 @@ pub struct Message {
|
||||
pub redact: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct User {
|
||||
pub userid: String,
|
||||
pub name: String,
|
||||
//TODO
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Room {
|
||||
pub roomid: String,
|
||||
//TODO
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Attachment {
|
||||
pub guid: String,
|
||||
//TODO
|
||||
|
||||
Reference in New Issue
Block a user