Struct rollo::server::SocketTools [−][src]
pub struct SocketTools {
pub socket_addr: SocketAddr,
pub id: u64,
// some fields omitted
}This is supported on crate feature
server only.Expand description
Send packets, latency, SocketTools etc.
Fields
socket_addr: SocketAddrid: u64Implementations
Send a packet to the session
Examples
use rollo::server::SocketTools;
fn on_message(socket: SocketTools) {
socket.send(1, None);
}Send Bytes(Packet) to the session
Examples
use rollo::server::SocketTools;
use rollo::packet::to_bytes;
fn on_message(socket: SocketTools) {
let bytes = to_bytes(1, None).freeze();
socket.send_data(bytes);
}get Latency
Examples
use rollo::server::SocketTools;
fn on_message(socket: SocketTools) {
let latency = socket.get_latency();
}pub fn send_flatbuffers<F: 'static + Fn(&mut FlatBufferBuilder<'static>) -> Bytes + Send + Sync>(
&self,
f: F
)
Close the session
Examples
use rollo::server::SocketTools;
fn on_message(socket: SocketTools) {
if socket.close().is_err() {
println!("Error when closing the session");
}
}Close the session with a delay
Examples
use rollo::server::SocketTools;
use std::time::Duration;
fn on_message(socket: SocketTools) {
if socket.close_with_delay(Duration::from_secs(1)).is_err() {
println!("Error when closing the session");
}
}Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for SocketTools
impl Send for SocketTools
impl Sync for SocketTools
impl Unpin for SocketTools
impl !UnwindSafe for SocketTools
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.
