[][src]Function solana_ws::listen

pub fn listen<A, F, H>(addr: A, factory: F) -> Result<()> where
    A: ToSocketAddrs + Debug,
    F: FnMut(Sender) -> H,
    H: Handler

A utility function for setting up a WebSocket server.

Safety

This function blocks until the event loop finishes running. Avoid calling this method within another WebSocket handler.

Examples

extern crate solana_ws as ws;
use ws::listen;

listen("127.0.0.1:3012", |out| {
    move |msg| {
       out.send(msg)
   }
}).unwrap()