WebSocket broadcast to all clients using Python -
i using simple python based web socket application:
from simplewebsocketserver import websocket, simplewebsocketserver class simpleecho(websocket): def handlemessage(self): if self.data none: self.data = '' # echo message client self.sendmessage(str(self.data)) def handleconnected(self): print self.address, 'connected' def handleclose(self): print self.address, 'closed' server = simplewebsocketserver('', 8000, simpleecho) server.serveforever()
it echoes messages sent each client same individual client, i trying send message received ws server clients connected it. can me please?
or this:
class simpleecho(websocket): def handlemessage(self): if self.data none: self.data = '' client in self.server.connections.itervalues(): client.sendmessage(str(self.address[0]) + ' - ' + str(self.data)) #echo message client #self.sendmessage(str(self.data)) def handleconnected(self): print self.address, 'connected' def handleclose(self): print self.address, 'closed'
Comments
Post a Comment