1
from twisted.spread import pb
3
class SingleClientWithAKickPerspective(pb.Perspective):
4
"""One client may attach to me at a time.
6
If a new client requests to be attached to me, any currently
7
connected perspective will be disconnected.
10
# This example is from twisted.words.service.Participant.
14
def __getstate__(self):
15
state = styles.Versioned.__getstate__(self)
22
def attached(self, client, identity):
23
if self.client is not None:
24
self.detached(client, identity)
28
def detached(self, client, identity):
31
# For the case where 'detached' was called by 'attached' wanting to
32
# kick someone off, is this all we need to do? I'm afraid not --
33
# no-one ever told the client that it had been detached! So the
34
# client, which will still have a reference to this perspective until
35
# its broker dies, will continue to execute methods on it, will
36
# continue to get results returned by those methods. It just won't get
37
# events sent to self.client. Meanwhile, the newly attached client
38
# will probably be confused, because its Perspective is doing things
39
# the new client did not ask it to do and it thinks it is the only