Skip to content

Commit

Permalink
add handshake; simple messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
rptr committed Jul 11, 2019
1 parent 4b1f9b1 commit e84b4f7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Binary file added .irp.py.swp
Binary file not shown.
22 changes: 20 additions & 2 deletions irp.py
Expand Up @@ -2,15 +2,33 @@

# server for js impress remote

from geventwebsocket import WebSocketServer, WebSocketApplication, Resource
import json
from collections import OrderedDict
from geventwebsocket import WebSocketServer, WebSocketApplication, Resource

class IRPApp (WebSocketApplication):
def on_open (self):
self.connected = False
print("new conn")

def on_message (self, message):
print("msg", message)

# handshake
if 'hello' == message:
self.ws.send('hello')
self.connected = True

elif None == message:
pass # disconnected

else:
print(message)
data = json.loads(message)
self.irp_msg(data)

def irp_msg (self, msg):
action = msg["action"]
print(action)

def on_close (self, reason):
print("close", reason)
Expand Down

0 comments on commit e84b4f7

Please sign in to comment.