-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEndpoint.py
More file actions
28 lines (23 loc) · 780 Bytes
/
Endpoint.py
File metadata and controls
28 lines (23 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import asyncore, socket
from config import config
import json
class Endpoint(asyncore.dispatcher):
def __init__(self, redsmin_prod):
asyncore.dispatcher.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.handshaken = False
#can be used in developpement environment
if(redsmin_prod):
self.connect(('ssl.redsmin.com', 993))
else:
self.connect(('ssl.redsmin.dev', 993))
#called when the socket is connected
def handle_connect(self):
print 'Endpoint connected'
#called when the socket is closed
def handle_close(self):
self.close()
print 'Endpoint closed'
#Redsmin needs a handshake
def handshake(self):
self.send(json.dumps({'version':"1.1.0", 'key':config['key'],'auth':config['auth']}))