Skip to content

Commit c9a9655

Browse files
Merge branch '0.9.2'
2 parents b425c97 + 648e1fe commit c9a9655

File tree

9 files changed

+7
-50
lines changed

9 files changed

+7
-50
lines changed

libs/ofxLibwebsockets/include/ofxLibwebsockets/Client.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ namespace ofxLibwebsockets {
6565
}
6666

6767
// send any binary data
68-
void sendBinary( ofBuffer buffer );
68+
void sendBinary( ofBuffer & buffer );
6969
void sendBinary( unsigned char * data, int size );
7070
void sendBinary( char * data, int size );
7171

@@ -76,7 +76,6 @@ namespace ofxLibwebsockets {
7676
ofAddListener( clientProtocol.oncloseEvent, app, &T::onClose);
7777
ofAddListener( clientProtocol.onidleEvent, app, &T::onIdle);
7878
ofAddListener( clientProtocol.onmessageEvent, app, &T::onMessage);
79-
ofAddListener( clientProtocol.onbroadcastEvent, app, &T::onBroadcast);
8079
}
8180

8281
// get pointer to libwebsockets connection wrapper

libs/ofxLibwebsockets/include/ofxLibwebsockets/Connection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace ofxLibwebsockets {
4747
sendBinary( (char *) image.getPixels().getData(), size );
4848
}
4949

50-
void sendBinary( ofBuffer buffer );
50+
void sendBinary( ofBuffer & buffer );
5151
void sendBinary( unsigned char * data, unsigned int size );
5252
void sendBinary( char * data, unsigned int size );
5353

libs/ofxLibwebsockets/include/ofxLibwebsockets/Events.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,4 @@ namespace ofxLibwebsockets {
3535
ofEvent<ofxLibwebsockets::Event> onClose;
3636
ofEvent<ofxLibwebsockets::Event> onIdle;
3737
ofEvent<ofxLibwebsockets::Event> onMessage;
38-
ofEvent<ofxLibwebsockets::Event> onBroadcast;
3938
};*/

libs/ofxLibwebsockets/include/ofxLibwebsockets/Protocol.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ namespace ofxLibwebsockets {
3333
virtual bool allowClient(const std::string name,
3434
const std::string ip) const;
3535

36-
void broadcast(const std::string& message);
37-
3836
unsigned int idx;
3937
unsigned int rx_buffer_size;
4038

@@ -49,7 +47,6 @@ namespace ofxLibwebsockets {
4947
virtual void onerror (Event& args);
5048
virtual void onidle (Event& args);
5149
virtual void onmessage (Event& args);
52-
virtual void onbroadcast(Event& args);
5350

5451
// internal events: called by Reactor
5552
ofEvent<Event> onconnectEvent;
@@ -58,7 +55,6 @@ namespace ofxLibwebsockets {
5855
ofEvent<Event> onerrorEvent;
5956
ofEvent<Event> onidleEvent;
6057
ofEvent<Event> onmessageEvent;
61-
ofEvent<Event> onbroadcastEvent;
6258

6359
bool defaultAllowPolicy;
6460
std::map<std::string, bool> allowRules;
@@ -74,7 +70,6 @@ namespace ofxLibwebsockets {
7470
void _onerror (Event& args);
7571
void _onidle (Event& args);
7672
void _onmessage (Event& args);
77-
void _onbroadcast (Event& args);
7873

7974
bool _allowClient(const std::string name,
8075
const std::string ip) const;

libs/ofxLibwebsockets/include/ofxLibwebsockets/Server.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ namespace ofxLibwebsockets {
5959
// close the server
6060
void close();
6161

62-
// broadcast a message to all connections
63-
void broadcast( string message );
64-
65-
// send to all connections
66-
// (sends normal message instead of broadcast)
62+
// send to all connections
6763
void send( string message );
6864

6965
// send anything that has pixels to all connections
@@ -81,7 +77,7 @@ namespace ofxLibwebsockets {
8177
}
8278

8379
// send any binary data to all connections
84-
void sendBinary( ofBuffer buffer );
80+
void sendBinary( ofBuffer & buffer );
8581
void sendBinary( unsigned char * data, int size );
8682
void sendBinary( char * data, int size );
8783

@@ -95,7 +91,6 @@ namespace ofxLibwebsockets {
9591
ofAddListener( serverProtocol.oncloseEvent, app, &T::onClose);
9692
ofAddListener( serverProtocol.onidleEvent, app, &T::onIdle);
9793
ofAddListener( serverProtocol.onmessageEvent, app, &T::onMessage);
98-
ofAddListener( serverProtocol.onbroadcastEvent, app, &T::onBroadcast);
9994
}
10095

10196
template<class T>
@@ -105,7 +100,6 @@ namespace ofxLibwebsockets {
105100
ofRemoveListener( serverProtocol.oncloseEvent, app, &T::onClose);
106101
ofRemoveListener( serverProtocol.onidleEvent, app, &T::onIdle);
107102
ofRemoveListener( serverProtocol.onmessageEvent, app, &T::onMessage);
108-
ofRemoveListener( serverProtocol.onbroadcastEvent, app, &T::onBroadcast);
109103
}
110104

111105
//getters

libs/ofxLibwebsockets/src/Client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ namespace ofxLibwebsockets {
226226
}
227227

228228
//--------------------------------------------------------------
229-
void Client::sendBinary( ofBuffer buffer ){
229+
void Client::sendBinary( ofBuffer & buffer ){
230230
if ( connection != NULL){
231231
connection->sendBinary(buffer);
232232
}

libs/ofxLibwebsockets/src/Connection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ namespace ofxLibwebsockets {
8282
}
8383

8484
//--------------------------------------------------------------
85-
void Connection::sendBinary( ofBuffer buffer ){
85+
void Connection::sendBinary( ofBuffer & buffer ){
8686
sendBinary(buffer.getData(), buffer.size());
8787
}
8888

libs/ofxLibwebsockets/src/Protocol.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ namespace ofxLibwebsockets {
2020
ofAddListener(oncloseEvent, this, &Protocol::_onclose);
2121
ofAddListener(onidleEvent, this, &Protocol::_onidle);
2222
ofAddListener(onmessageEvent, this, &Protocol::_onmessage);
23-
ofAddListener(onbroadcastEvent, this, &Protocol::_onbroadcast);
2423
ofAddListener(onerrorEvent, this, &Protocol::_onerror);
2524
rx_buffer_size = OFX_LWS_MAX_BUFFER;
2625
idle = false;
@@ -33,7 +32,6 @@ namespace ofxLibwebsockets {
3332
ofRemoveListener(oncloseEvent, this, &Protocol::_onclose);
3433
ofRemoveListener(onidleEvent, this, &Protocol::_onidle);
3534
ofRemoveListener(onmessageEvent, this, &Protocol::_onmessage);
36-
ofRemoveListener(onbroadcastEvent, this, &Protocol::_onbroadcast);
3735
ofRemoveListener(onerrorEvent, this, &Protocol::_onerror);
3836
rx_buffer_size = OFX_LWS_MAX_BUFFER;
3937
idle = false;
@@ -94,24 +92,4 @@ namespace ofxLibwebsockets {
9492
}
9593

9694
void Protocol::onmessage(Event&args){}
97-
98-
//--------------------------------------------------------------
99-
void Protocol::_onbroadcast(Event& args){ onbroadcast(args); }
100-
101-
void Protocol::onbroadcast(Event&args){ args.conn.send(args.message); }
102-
103-
//--------------------------------------------------------------
104-
void Protocol::broadcast(const std::string& message){
105-
std::string buf(LWS_SEND_BUFFER_PRE_PADDING+message.size()+LWS_SEND_BUFFER_POST_PADDING, 0);
106-
unsigned char *p = (unsigned char*)&buf[LWS_SEND_BUFFER_PRE_PADDING];
107-
108-
if (reactor != NULL)
109-
{
110-
memcpy(p, message.c_str(), message.size());
111-
//int n = libwebsockets_broadcast(&reactor->lws_protocols[idx], p, message.size());
112-
int n = libwebsocket_callback_on_writable_all_protocol(&reactor->lws_protocols[idx]);
113-
if (n < 0)
114-
fprintf(stderr, "ERROR writing to socket");
115-
}
116-
}
11795
}

libs/ofxLibwebsockets/src/Server.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,6 @@ namespace ofxLibwebsockets {
149149
}
150150
libwebsocket_context_destroy(context);
151151
}
152-
153-
//--------------------------------------------------------------
154-
void Server::broadcast( string message ){
155-
// loop through all protocols and broadcast!
156-
for (int i=0; i<protocols.size(); i++){
157-
protocols[i].second->broadcast( message );
158-
}
159-
}
160152

161153
//--------------------------------------------------------------
162154
void Server::send( string message ){
@@ -168,7 +160,7 @@ namespace ofxLibwebsockets {
168160
}
169161

170162
//--------------------------------------------------------------
171-
void Server::sendBinary( ofBuffer buffer ){
163+
void Server::sendBinary( ofBuffer & buffer ){
172164
sendBinary(buffer.getData(), buffer.size());
173165
}
174166

0 commit comments

Comments
 (0)