I have the below websocket server taking connections from web clients, and broadcasting data to all of the clients when certain keys are pressed on any of the clients. Everything is working just fine in that sector. I have two external Python applications doing various things on the server, however, and I need the websocket server to respond to their activities, as well. How can I connect to the websocket server from those applications, or is it even possible?
websocket server:
class Control(WebSocket):
def handle(self):
if self.data == "Left":
Return = update.leftArrow()
ClassValues = read_Class()
LineValue = read_Line()
message = "Line " + str(ClassValues[Return[1]][LineValue[Return[1]]])
elif self.data == "Right":
Return = update.rightArrow()
LineValue = read_Line()
message = "Line " + str(ClassValues[Return[1]][LineValue[Return[1]]])
elif self.data == "Up":
Return = update.upArrow()
message = "Control " + str(Return[1])
elif self.data == "Down":
Return = update.downArrow()
message = "Control " + str(Return[1])
else:
Return = [False, 0]
if Return[0]:
for client in self.server.connections.itervalues():
client.sendMessage(message)
server = WebSocketServer('', 8000, Control)
server.serve_forever()