[][src]Struct pushevent::server::Server

pub struct Server { /* fields omitted */ }

The main server struct that gets returned when a ws server is opened. It encapsulates a vector of thread join handles, which holds mainly our Websocket server thread and a thread which receives messages from our mpsc channel. It also holds our inner ServerRef which you probably don't need to touch.

Methods

impl Server[src]

pub fn new(addr: &'static str) -> Self[src]

Returns a server instance. As soon as this method is called, a websocket server is opened and a thread will start accepting events to be published.

Arguments

  • addr - Static string slice which holds the address on which to open the websocket server

Example

use pushevent::server::Server;
let server = Server::new("127.0.0.1:3012");

pub fn get_tx(&self) -> Sender<Event>[src]

Clones and returns a mpsc tx channel through which we can send events of Event type.

Example

This example deliberately fails to compile
use std::thread;

let server = Server::new("127.0.0.1:3012");

loop {
    let tx = server.get_tx();
    let _ = std::thread::spawn(move || {
        tx.send(...);
    });
}

pub fn join_threads(&mut self)[src]

This method cleans up all of our threads and should be called on exit of your main application. It drains all threads from self.threads and tries to join them.

Example

use pushevent::server::Server;
let mut server = Server::new("127.0.0.1:3012");
server.join_threads();

Auto Trait Implementations

impl Send for Server

impl !Sync for Server

impl Unpin for Server

impl !UnwindSafe for Server

impl !RefUnwindSafe for Server

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,