Package foolscap :: Module banana :: Class Banana
[hide private]
[frames] | no frames]

Class Banana

source code

twisted.internet.protocol.BaseProtocol --+    
                                         |    
        twisted.internet.protocol.Protocol --+
                                             |
                                            Banana
Known Subclasses:

Nested Classes [hide private]
  slicerClass
  unslicerClass
Instance Methods [hide private]
 
__init__(self, features={}) source code
 
populateVocabTable(self, vocabStrings)
I expect a list of strings.
source code
 
connectionMade(self)
Called when a connection is made.
source code
 
connectionLost(self, why)
Called when the connection is shut down.
source code
 
initSend(self) source code
 
initSlicer(self) source code
 
send(self, obj) source code
 
_slice_error(self, f, s) source code
 
produce(self, dummy=None) source code
 
handleSendViolation(self, f, doPop, sendAbort) source code
 
newSlicerFor(self, obj) source code
 
pushSlicer(self, slicer, obj) source code
 
popSlicer(self) source code
 
describeSend(self) source code
 
setOutgoingVocabulary(self, vocabStrings)
Schedule a replacement of the outbound VOCAB table.
source code
 
addToOutgoingVocabulary(self, value)
Schedule 'value' for addition to the outbound VOCAB table.
source code
 
outgoingVocabTableWasReplaced(self, newTable) source code
 
allocateEntryInOutgoingVocabTable(self, string) source code
 
outgoingVocabTableWasAmended(self, index, string) source code
 
sendPING(self, number=0) source code
 
sendPONG(self, number) source code
 
sendOpen(self) source code
 
sendToken(self, obj) source code
 
maybeVocabizeString(self, string) source code
 
sendClose(self, openID) source code
 
sendAbort(self, count=0) source code
 
sendError(self, msg) source code
 
sendFailed(self, f) source code
 
initReceive(self) source code
 
initUnslicer(self) source code
 
printStack(self, verbose=0) source code
 
setObject(self, count, obj) source code
 
getObject(self, count) source code
 
replaceIncomingVocabulary(self, vocabDict) source code
 
addIncomingVocabulary(self, key, value) source code
 
dataReceived(self, chunk)
Called whenever data is received.
source code
 
keepaliveTimerFired(self) source code
 
disconnectTimerFired(self) source code
 
connectionTimedOut(self) source code
 
reportReceiveError(self, f) source code
 
handleData(self, chunk) source code
 
handleOpen(self, openCount, indexToken) source code
 
handleToken(self, token, ready_deferred=None) source code
 
handleClose(self, closeCount) source code
 
handleViolation(self, f, methname, inOpen=False, inClose=False)
An Unslicer has decided to give up, or we have given up on it (because we received an ABORT token).
source code
 
handleError(self, msg) source code
 
describeReceive(self) source code
 
receivedObject(self, obj)
Decoded objects are delivered here, unless you use a RootUnslicer variant which does something else in its .childFinished method.
source code
 
reportViolation(self, why) source code

Inherited from twisted.internet.protocol.BaseProtocol: __providedBy__, makeConnection

Class Variables [hide private]
  paused = False
  streamable = True
  debugSend = False
  debugReceive = False
  logViolations = False
  logReceiveErrors = True
  useKeepalives = False
  keepaliveTimeout = None
  keepaliveTimer = None
  disconnectTimeout = None
  disconnectTimer = None
  __implemented__ = <implementedBy foolscap.banana.Banana>
  __provides__ = <zope.interface.declarations.ClassProvides obje...

Inherited from twisted.internet.protocol.BaseProtocol: connected, transport

Method Details [hide private]

__init__(self, features={})
(Constructor)

source code 
Parameters:
  • features - a dictionary of negotiated connection features

populateVocabTable(self, vocabStrings)

source code 

I expect a list of strings. I will populate my initial vocab table (both inbound and outbound) with this list.

It is not safe to use this method once anything has been serialized onto the wire. This method can only be used to set up the initial vocab table based upon a negotiated set of common words. The 'initial-vocab-table-index' parameter is used to decide upon the contents of this table.

connectionMade(self)

source code 

Called when a connection is made.

This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.

Overrides: twisted.internet.protocol.BaseProtocol.connectionMade
(inherited documentation)

connectionLost(self, why)

source code 

Called when the connection is shut down.

Clear any circular references here, and any external references to this Protocol. The connection has been closed.

Overrides: twisted.internet.protocol.Protocol.connectionLost
(inherited documentation)

setOutgoingVocabulary(self, vocabStrings)

source code 

Schedule a replacement of the outbound VOCAB table.

Higher-level code may call this at any time with a list of strings. Immediately after the replacement has occured, the outbound VOCAB table will contain all of the strings in vocabStrings and nothing else. This table tells the token-sending code which strings to abbreviate with short integers in a VOCAB token.

This function can be called at any time (even while the protocol is in the middle of serializing and transmitting some other object) because it merely schedules a replacement to occur at some point in the future. A special marker (the ReplaceVocabSlicer) is placed in the outbound queue, and the table replacement will only happend after all the items ahead of that marker have been serialized. At the same time the table is replaced, a (set-vocab..) sequence will be serialized towards the far end. This insures that we set our outbound table at the same 'time' as the far end starts using it.

addToOutgoingVocabulary(self, value)

source code 

Schedule 'value' for addition to the outbound VOCAB table.

This may be called at any time. If the string is already scheduled for addition, or if it is already in the VOCAB table, it will be ignored. (TODO: does this introduce an annoying-but-not-fatal race condition?) The string will not actually be added to the table until the outbound serialization queue has been serviced.

dataReceived(self, chunk)

source code 

Called whenever data is received.

Use this method to translate to a higher-level message. Usually, some callback will be made upon the receipt of each complete protocol message.

Parameters:
  • data - a string of indeterminate length. Please keep in mind that you will probably need to buffer some data, as partial (or multiple) protocol messages may be received! I recommend that unit tests for protocols call through to this method with differing chunk sizes, down to one byte at a time.
Overrides: twisted.internet.protocol.Protocol.dataReceived
(inherited documentation)

Class Variable Details [hide private]

__provides__

Value:
<zope.interface.declarations.ClassProvides object at 0x87194ec>