Ticket #1985: amp-requiresanswer.py

File amp-requiresanswer.py, 713 bytes (added by Richard Wall, 16 years ago)

A simple example of how I came across this.

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