~ntt-pf-lab/nova/monkey_patch_notification

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/conch/examples/telnet_echo.tac

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2009 Twisted Matrix Laboratories.
 
2
# See LICENSE for details.
 
3
 
 
4
from twisted.conch.telnet import TelnetTransport, TelnetProtocol
 
5
from twisted.internet.protocol import ServerFactory
 
6
from twisted.application.internet import TCPServer
 
7
from twisted.application.service import Application
 
8
 
 
9
class TelnetEcho(TelnetProtocol):
 
10
    def enableRemote(self, option):
 
11
        self.transport.write("You tried to enable %r (I rejected it)\r\n" % (option,))
 
12
        return False
 
13
 
 
14
 
 
15
    def disableRemote(self, option):
 
16
        self.transport.write("You disabled %r\r\n" % (option,))
 
17
 
 
18
 
 
19
    def enableLocal(self, option):
 
20
        self.transport.write("You tried to make me enable %r (I rejected it)\r\n" % (option,))
 
21
        return False
 
22
 
 
23
 
 
24
    def disableLocal(self, option):
 
25
        self.transport.write("You asked me to disable %r\r\n" % (option,))
 
26
 
 
27
 
 
28
    def dataReceived(self, data):
 
29
        self.transport.write("I received %r from you\r\n" % (data,))
 
30
 
 
31
 
 
32
factory = ServerFactory()
 
33
factory.protocol = lambda: TelnetTransport(TelnetEcho)
 
34
service = TCPServer(8023, factory)
 
35
 
 
36
application = Application("Telnet Echo Server")
 
37
service.setServiceParent(application)