From 24e8266870a688d01cea07e910aa1aa66403cb30 Mon Sep 17 00:00:00 2001 From: melode11 Date: Tue, 7 Apr 2015 14:06:10 +0800 Subject: [PATCH] update readme for new interfaces --- README.md | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 2432ff1..0c05147 100755 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ By virtue of being written in C++, this client works in several different platfo 1. Install boost 2. Use `git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git` to clone your local repo. -3. Include `websocket++`, `rapidjson` and `sio_client.cpp`,`sio_packet.cpp` in your project. +3. Include `websocket++`, `rapidjson` and `sio_client.cpp`,`sio_packet.cpp`,`sio_socket.cpp`,`internal/sio_client_impl.cpp` in your project. 4. Include `sio_client.h` where you want to use it. 5. Use `message` and its derived classes to compose complex text/binary messages. @@ -74,11 +74,15 @@ Unbind the event callback with specified name. `void off_all()` -Clear all event bindings. +Clear all event bindings (not including the error listener). -`void set_error_listener(error_listener const& l)` +`void on_error(error_listener const& l)` -Set the error handler for socket.io error messages. +Bind the error handler for socket.io error messages. + +`void off_error()` + +Unbind the error handler. ```C++ @@ -108,15 +112,6 @@ Set the error handler for socket.io error messages. ``` -#### Listeners -`void set_connect_listener(con_listener const& l)` - -Set listener for connect event, called when server notify socket is joined the namespace. - -`void set_close_listener(con_listener const& l)` - -Set listener for close event, called when server notify socket is kicked from namespace. `socket` object will be destroyed after close event. - #### Connect and close socket `connect` will happen for existing `socket`s automatically when `client` have opened up the physical connection. @@ -159,6 +154,20 @@ typedef std::function con_listener; typedef std::function close_listener; ``` +#### Socket listeners +`void set_connect_listener(socket_listener const& l)` + +Set listener for socket connect event, called when any sockets being ready to send message. + +`void set_close_listener(socket_listener const& l)` + +Set listener for socket close event, called when any sockets being closed, afterward, corresponding `socket` object will be cleared from client. + +```C++ + //socket_listener declare: + typedef std::function socket_listener; +``` + #### Connect and Close `void connect(const std::string& uri)`