Struct msg_transmitter::tcp::TCPMsgServer [−][src]
pub struct TCPMsgServer<T> { pub addr: SocketAddr, pub name: String, pub connections: Arc<Mutex<HashMap<String, Sender<Option<T>>>>>, }
Fields
addr: SocketAddr
name: String
connections: Arc<Mutex<HashMap<String, Sender<Option<T>>>>>
Methods
impl<T> TCPMsgServer<T> where
T: DeserializeOwned + Serialize + Send + 'static + Clone,
[src]
impl<T> TCPMsgServer<T> where
T: DeserializeOwned + Serialize + Send + 'static + Clone,
pub fn new(addr: &str, server_name: &str) -> TCPMsgServer<T>
[src]
pub fn new(addr: &str, server_name: &str) -> TCPMsgServer<T>
addr is socket address. like: 127.0.0.1:6666. name is the server's name, to identity which server it is.
pub fn start_server<F>(
&self,
first_msg: T,
process_function: F
) -> Box<Future<Item = (), Error = ()> + Send + 'static> where
F: FnMut(String, T) -> Vec<(String, T)> + Send + Sync + 'static + Clone,
[src]
pub fn start_server<F>(
&self,
first_msg: T,
process_function: F
) -> Box<Future<Item = (), Error = ()> + Send + 'static> where
F: FnMut(String, T) -> Vec<(String, T)> + Send + Sync + 'static + Clone,
first_msg is the first message that server send to the client which just connect to server. process_fuction receive a tuple of <client_name, message>, and return a series of tuple of (client_name,message) indicating which message will be sent to which client. Note that if you want to send a message to current client, you should set client_name as a string with 0 length, i.e. "" .
Trait Implementations
impl<T: Debug> Debug for TCPMsgServer<T>
[src]
impl<T: Debug> Debug for TCPMsgServer<T>
Auto Trait Implementations
impl<T> Send for TCPMsgServer<T> where
T: Send,
impl<T> Send for TCPMsgServer<T> where
T: Send,
impl<T> Sync for TCPMsgServer<T> where
T: Send,
impl<T> Sync for TCPMsgServer<T> where
T: Send,