Skip to content

Commit 24e8266

Browse files
committed
update readme for new interfaces
1 parent 2e2fb30 commit 24e8266

1 file changed

Lines changed: 22 additions & 13 deletions

File tree

README.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ By virtue of being written in C++, this client works in several different platfo
1818

1919
1. Install boost
2020
2. Use `git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git` to clone your local repo.
21-
3. Include `websocket++`, `rapidjson` and `sio_client.cpp`,`sio_packet.cpp` in your project.
21+
3. Include `websocket++`, `rapidjson` and `sio_client.cpp`,`sio_packet.cpp`,`sio_socket.cpp`,`internal/sio_client_impl.cpp` in your project.
2222
4. Include `sio_client.h` where you want to use it.
2323
5. Use `message` and its derived classes to compose complex text/binary messages.
2424

@@ -74,11 +74,15 @@ Unbind the event callback with specified name.
7474

7575
`void off_all()`
7676

77-
Clear all event bindings.
77+
Clear all event bindings (not including the error listener).
7878

79-
`void set_error_listener(error_listener const& l)`
79+
`void on_error(error_listener const& l)`
8080

81-
Set the error handler for socket.io error messages.
81+
Bind the error handler for socket.io error messages.
82+
83+
`void off_error()`
84+
85+
Unbind the error handler.
8286

8387
```C++
8488

@@ -108,15 +112,6 @@ Set the error handler for socket.io error messages.
108112

109113
```
110114
111-
#### Listeners
112-
`void set_connect_listener(con_listener const& l)`
113-
114-
Set listener for connect event, called when server notify socket is joined the namespace.
115-
116-
`void set_close_listener(con_listener const& l)`
117-
118-
Set listener for close event, called when server notify socket is kicked from namespace. `socket` object will be destroyed after close event.
119-
120115
#### Connect and close socket
121116
`connect` will happen for existing `socket`s automatically when `client` have opened up the physical connection.
122117
@@ -159,6 +154,20 @@ typedef std::function<void(void)> con_listener;
159154
160155
typedef std::function<void(close_reason const& reason)> close_listener;
161156
```
157+
#### Socket listeners
158+
`void set_connect_listener(socket_listener const& l)`
159+
160+
Set listener for socket connect event, called when any sockets being ready to send message.
161+
162+
`void set_close_listener(socket_listener const& l)`
163+
164+
Set listener for socket close event, called when any sockets being closed, afterward, corresponding `socket` object will be cleared from client.
165+
166+
```C++
167+
//socket_listener declare:
168+
typedef std::function<void(std::string const& nsp)> socket_listener;
169+
```
170+
162171
#### Connect and Close
163172
`void connect(const std::string& uri)`
164173

0 commit comments

Comments
 (0)