From ca572f272b9f311b875973cb873c214a712c6bdb Mon Sep 17 00:00:00 2001 From: melode11 Date: Thu, 2 Apr 2015 21:09:28 +0800 Subject: [PATCH] Update README for new interfaces. --- README.md | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e3e53e7..0a5916a 100755 --- a/README.md +++ b/README.md @@ -50,7 +50,9 @@ Emit a single binary buffer, along with event's name and a optional ack callback ### Event Bindings `void bind_event(std::string const& event_name,event_listener const& func)` -Bind a callback to specified event name. Same as `socket.on` function in JS. +`void bind_event(std::string const& event_name,event_listener_aux const& func)` + +Bind a callback to specified event name. Same as `socket.on()` function in JS, `event_listener` is for full content event object,`event_listener_aux` is for convinience. `void unbind_event(std::string const& event_name)` @@ -62,6 +64,8 @@ Clear all event bindings. `void set_default_event_listener(event_listener const& l)` +`void set_default_event_listener(event_listener_aux const& l)` + Set a default event handler for events with no binding functions. `void set_error_listener(error_listener const& l)` @@ -69,9 +73,28 @@ Set a default event handler for events with no binding functions. Set the error handler for socket.io error messages. ```C++ -//event listener declare: -typedef std::function event_listener; +//event object: +class event + { + public: + const std::string& get_nsp() const; + const std::string& get_name() const; + + const message::ptr& get_message() const; + + bool need_ack() const; + + void put_ack_message(message::ptr const& ack_message); + + message::ptr const& get_ack_message() const; + ... + }; +//event listener declare: +typedef std::function event_listener_aux; + +typedef std::function event_listener; + typedef std::function error_listener; ``` @@ -130,6 +153,10 @@ Check if client is connected. Add namespace part `/[any namespaces]` after port, will automatically connect to the namespace you specified. +`std::string const& get_namespace() const` + +Get current namespace which the client is inside. + ### Session ID `std::string const& get_sessionid() const`