[Twisted-Python] Help implement protocol
jacob at internet24.de
Mon Aug 7 05:16:37 EDT 2006
Maybe you want to take a look at the FTPClientBasic class
There the author basically uses a queue of actions (=hand shakes) to
be run, associating response lines to commands, and returning
the results via deferreds....
On Sat, 2006-08-05 at 11:44 +0800, Keith Cheung (張國良) wrote:
> Hi all,
> I want to implement some handshake protocol, say..
> 1. Client: WhatDate
> 2. Server: 5Aug
> 3. Client: WhatYear
> 4. Server: 2006
> 5. Client: WhatTime
> 6. Server: 1005
> So, for the client:- (pseudo code)
> def connectionMade():
> send "WhatDate"
> state = askingForDate
> def lineReceived(data):
> switch state:
> date = data
> send "WhatYear"
> state = askingForYear
> year = data
> send = "WhatTime"
> state = askingForTime
> time = data
> state = initialState
> The switch case becomes gigantic as the protocol grow. Instead of keeping states, are there better ways to implement?
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 191 bytes
Desc: This is a digitally signed message part
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20060807/02235788/attachment.pgp
More information about the Twisted-Python