1
- # WebsocketRailsClient++ (v0.7.3 )
1
+ # WebsocketRailsClient++ (v0.7.4 )
2
2
3
3
WebsocketRailsClient++ is a C++ library that uses the implementation of RFC6455 (The WebSocket Protocol)
4
4
implemented in the WebSocket++ library, the Json++ light-weight JSON parser and the Boost library. It allows
@@ -35,9 +35,9 @@ connections to the Ruby Websocket-Rails server and supports the Websocket-Rails
35
35
36
36
#### Connection Callbacks
37
37
38
- * ``` on_open (boost::bind cb)``` : callback on open connection.
39
- * ``` on_close (boost::bind cb)``` : callback on close connection.
40
- * ``` on_fail (boost::bind cb)``` : callback on fail connection.
38
+ * ``` onOpen (boost::bind cb)``` : callback on open connection.
39
+ * ``` onClose (boost::bind cb)``` : callback on close connection.
40
+ * ``` onFail (boost::bind cb)``` : callback on fail connection.
41
41
42
42
#### Trigger an Event on Server
43
43
@@ -56,6 +56,7 @@ connections to the Ruby Websocket-Rails server and supports the Websocket-Rails
56
56
57
57
#### Channel Management
58
58
59
+ * ``` getChannel(std::string channel_name) ``` : Get a channel after subscribed to it.
59
60
* ``` subscribe(std::string channel_name) ``` : Subscribe to a channel.
60
61
* ``` subscribePrivate(std::string channel_name, boost::bind cb_succ, boost::bind cb_fail) ``` : Subscribe to a private channel with callbacks.
61
62
* ``` unsubscribe(std::string channel_name) ``` : Unsubscribe a channel.
@@ -64,7 +65,6 @@ connections to the Ruby Websocket-Rails server and supports the Websocket-Rails
64
65
#### Trigger a Channel-Event on Server
65
66
66
67
* ``` trigger(std::string event_name, jsonxx::Object event_data) ``` : trigger channel event with data without callback.
67
- * ``` trigger(std::string event_name, jsonxx::Object event_data, boost::bind cb_succ, boost::bind cb_fail) ``` : trigger channel event with data and callbacks.
68
68
69
69
#### Bind to an Incoming Channel-Event
70
70
@@ -147,36 +147,36 @@ dispatcher.connect();
147
147
148
148
``` cpp
149
149
/* Event bind callback definition */
150
- dispatcher.bind(" users.pool " , boost::bind(callback, _1));
150
+ dispatcher.bind(" users_pool " , boost::bind(callback, _1));
151
151
152
152
/* Event bind callback definition with member function callback */
153
153
Foo my_foo;
154
- Event event3 = dispatcher.bind(" users.pool " , boost::bind(&Foo::success_func, my_foo, _1));
154
+ dispatcher.bind(" users_pool " , boost::bind(&Foo::success_func, my_foo, _1));
155
155
156
156
/* Event unbind callback definition */
157
- dispatcher.unbindAll(" users.pool " );
157
+ dispatcher.unbindAll(" users_pool " );
158
158
```
159
159
160
160
* Trigger events
161
161
162
162
``` cpp
163
163
/* Trigger an event */
164
- Event event1 = dispatcher.trigger(" users.create " , jsonxx::Object(" name" , " Hans Mustermann" ));
165
- Event event2 = dispatcher.trigger(" users.create " , jsonxx::Object(" name" , " Frau Mustermann" ), boost::bind(success_func, _1), boost::bind(failure_func, _1));
164
+ dispatcher.trigger(" users_create " , jsonxx::Object(" name" , " Hans Mustermann" ));
165
+ dispatcher.trigger(" users_create " , jsonxx::Object(" name" , " Frau Mustermann" ), boost::bind(success_func, _1), boost::bind(failure_func, _1));
166
166
167
167
/* Trigger an event with member function callback */
168
168
Bar my_bar;
169
- Event event3 = dispatcher.trigger(" users.pool " , boost::bind(&Foo::success_func, my_bar, _1), boost::bind(&Foo::failure_func, my_bar, _1));
169
+ dispatcher.trigger(" users_pool " , boost::bind(&Foo::success_func, my_bar, _1), boost::bind(&Foo::failure_func, my_bar, _1));
170
170
```
171
171
172
172
* Use channels
173
173
174
174
``` cpp
175
175
/* Subscribe to channels */
176
- Channel channel1 = dispatcher.subscribe(" Authors" );
177
- Channel channel2 = dispatcher.subscribe(" Users" , boost::bind(success_func, _1), boost::bind(failure_func, _1));
178
- Channel private_channel1 = dispatcher.subscribePrivate(" Administrators" );
179
- Channel private_channel2 = dispatcher.subscribePrivate(" Moderators" , boost::bind(success_func, _1), boost::bind(failure_func, _1));
176
+ dispatcher.subscribe(" Authors" );
177
+ dispatcher.subscribe(" Users" , boost::bind(success_func, _1), boost::bind(failure_func, _1));
178
+ dispatcher.subscribePrivate(" Administrators" );
179
+ dispatcher.subscribePrivate(" Moderators" , boost::bind(success_func, _1), boost::bind(failure_func, _1));
180
180
181
181
/* Unsubscribe channels */
182
182
dispatcher.unsubscribe(" Authors" );
@@ -187,14 +187,13 @@ dispatcher.unsubscribe("Users", boost::bind(success_func, _1), boost::bind(failu
187
187
188
188
``` cpp
189
189
/* Trigger an event on channel */
190
- Event event = channel1.trigger(" users.create" , jsonxx::Object(" name" , " Hans Mustermann" ));
191
- Event event = channel2.trigger(" users.create" , jsonxx::Object(" name" , " Frau Mustermann" ), boost::bind(success_func, _1), boost::bind(failure_func, _1));
190
+ dispatcher.getChannel(" Authors" ).trigger(" users_create" , jsonxx::Object(" name" , " Hans Mustermann" ));
192
191
193
192
/* Channel event bind callback definition */
194
- channel1.bind( " users.pool " , boost::bind(callback, _1));
193
+ dispatcher.getChannel( " Authors " ).bind( " users_pool " , boost::bind(callback, _1));
195
194
196
195
/* Event unbind callback definition */
197
- channel1.unbindAll( " users.pool " );
196
+ dispatcher.getChannel( " Authors " ).unbindAll( " users_pool " );
198
197
```
199
198
200
199
* Callback additional parameters
0 commit comments