PageRenderTime 47ms CodeModel.GetById 39ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/net/client.py

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