PageRenderTime 14ms CodeModel.GetById 1ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/net/server.py

https://bitbucket.org/prologic/circuits/
Python | 42 lines | 37 code | 5 blank | 0 comment | 0 complexity | dfc54258f4be96a6793d6ffc399ec3c7 MD5 | raw file
 1from circuits import Component
 2from circuits.net.events import write
 3
 4
 5class Server(Component):
 6
 7    channel = "server"
 8
 9    def __init__(self):
10        super(Server, self).__init__()
11
12        self.data = ""
13        self.host = None
14        self.port = None
15        self.client = None
16        self.ready = False
17        self.closed = False
18        self.connected = False
19        self.disconnected = False
20
21    def ready(self, server, bind):
22        self.ready = True
23        self.host, self.port = bind
24
25    def close(self):
26        return
27
28    def closed(self):
29        self.closed = True
30
31    def connect(self, sock, *args):
32        self.connected = True
33        self.client = args
34        self.fire(write(sock, b"Ready"))
35
36    def disconnect(self, sock):
37        self.client = None
38        self.disconnected = True
39
40    def read(self, sock, data):
41        self.data = data
42        return data