Struct rump::client::Session
[−]
[src]
pub struct Session<S: WampSender> { // some fields omitted }
A Session represents a valid WAMP Session with a Router.
You can obtain a Session
from a Client
Methods
impl<S: WampSender> Session<S>
fn join(&self, realm: String) -> WampResult<()>
Connects to a WAMP Router in a realm without authentication
fn publish<A, K>(&self, topic: &str, args: Vec<A>, kwargs: K) where A: Encodable, K: Encodable
Publish an event to the realm
You can publish 0 or more positional arguments and/or a struct representings Key-Value pairs that have the Encodable trait (can be derived from RustcEncodable, see rustc_serialize docs for more details).
Examples
To send an empty publish event...
use rump::message::WampType; session.publish("com.example.topic", Vec::new(), WampType::None);
To send the example positions arguments (42, "foo") and key word arguments...
This library includes a helper enum WampType that makes it easy to encode primitive positional arguments and keyword argument maps.
use rump::message::WampType; extern crate rustc_serialize; use rustc_serialize::Encodable; #[derive(RustcEncodable)] struct CustomKwargs { key1: String, key2: u32 } session.publish("com.example.topic", vec![WampType::i32(42), WampType::String("foo".to_string())], CustomKwargs {key1: "hello".to_string(), key2: 19});