1 | from twisted.internet import reactor |
---|
2 | from twisted.internet.protocol import ClientCreator |
---|
3 | from twisted.protocols import amp |
---|
4 | |
---|
5 | # Server |
---|
6 | class CdPlay(amp.Command): |
---|
7 | requiresAnswer = False |
---|
8 | |
---|
9 | class CdControlProtocol(amp.AMP): |
---|
10 | def play(self): |
---|
11 | pass |
---|
12 | CdPlay.responder(play) |
---|
13 | |
---|
14 | |
---|
15 | d = ClientCreator(reactor, amp.AMP).connectTCP('127.0.0.1', 8080) |
---|
16 | d.addCallback(lambda p: p.callRemote(CdPlay)) |
---|
17 | |
---|
18 | # Tac stuff |
---|
19 | from twisted.application import internet, service |
---|
20 | from twisted.internet.protocol import Factory |
---|
21 | |
---|
22 | application = service.Application('CdRemoteControl') |
---|
23 | factory = Factory() |
---|
24 | factory.protocol = CdControlProtocol |
---|
25 | cdService = internet.TCPServer(8080, factory) |
---|
26 | cdService.setServiceParent(application) |
---|