Skip to content

Commit 7952f01

Browse files
Removed defunct broadcast methods/events
1 parent da28a48 commit 7952f01

File tree

6 files changed

+1
-44
lines changed

6 files changed

+1
-44
lines changed

libs/ofxLibwebsockets/include/ofxLibwebsockets/Client.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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/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: 1 addition & 7 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
@@ -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/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: 0 additions & 8 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 ){

0 commit comments

Comments
 (0)