class documentation

class ProtocolSwitchCommand(Command): (source)

View In Hierarchy

Use this command to switch from something Amp-derived to a different protocol mid-connection. This can be useful to use amp as the connection-startup negotiation phase. Since TLS is a different layer entirely, you can use Amp to negotiate the security parameters of your connection, then switch to a different protocol, and the connection will remain secured.
Class Method make​Response Serialize a mapping of arguments using this Command's response schema.
Method __init__ Create a ProtocolSwitchCommand.
Instance Variable proto​To​Switch​To​Factory Undocumented
Method _do​Command When we emit a ProtocolSwitchCommand, lock the protocol, but don't actually switch to the new protocol unless an acknowledgement is received. If an error is received, switch back.

Inherited from Command:

Class __metaclass__ Metaclass hack to establish reverse-mappings for 'errors' and 'fatalErrors' as class vars.
Class Method make​Arguments Serialize a mapping of arguments using this Command's argument schema.
Class Method parse​Arguments Parse a mapping of serialized arguments using this Command's argument schema.
Class Method parse​Response Parse a mapping of serialized arguments using this Command's response schema.
Class Method responder Declare a method to be a responder for a particular command.
Class Variable arguments A list of 2-tuples of (name, Argument-subclass-instance), specifying the names and values of the parameters which are required for this command.
Class Variable command​Type The type of Box used to issue commands; useful only for protocol-modifying behavior like startTLS or protocol switching. Defaults to a plain vanilla Box.
Class Variable errors A mapping of subclasses of Exception to wire-protocol tags for errors represented as strs. Responders which raise keys from this dictionary will have the error translated to the corresponding tag on the wire. Invokers which receive Deferreds from invoking this command with BoxDispatcher.callRemote will potentially receive Failures with keys from this mapping as their value. This mapping is inherited; if you declare a command which handles FooError as 'FOO_ERROR', then subclass it and specify BarError as 'BAR_ERROR', responders to the subclass may raise either FooError or BarError, and invokers must be able to deal with either of those exceptions.
Class Variable extra Undocumented
Class Variable fatal​Errors like 'errors', but errors in this list will always terminate the connection, despite being of a recognizable error type.
Class Variable response A list like arguments, but instead used for the return value.
Class Variable response​Type The type of Box used to respond to this command; only useful for protocol-modifying behavior like startTLS or protocol switching. Defaults to a plain vanilla Box.
Instance Variable requires​Answer a boolean; defaults to True. Set it to False on your subclass if you want callRemote to return None. Note: this is a hint only to the client side of the protocol. The return-type of a command responder method must always be a dictionary adhering to the contract specified by response, because clients are always free to request a response if they want one.
Instance Variable structured Undocumented
@classmethod
def makeResponse(cls, innerProto, proto): (source)
Serialize a mapping of arguments using this Command's response schema.
Parameters
inner​ProtoUndocumented
protoan AMP.
objectsa dict with keys matching the names specified in self.response, having values of the types that the Argument objects in self.response can format.
Returns
an AmpBox.
def __init__(self, _protoToSwitchToFactory, **kw): (source)
Create a ProtocolSwitchCommand.
Parameters
_proto​To​Switch​To​Factorya ProtocolFactory which will generate the Protocol to switch to.
**kwKeyword arguments, encoded and handled normally as Command would.
protoToSwitchToFactory = (source)

Undocumented

def _doCommand(self, proto): (source)
When we emit a ProtocolSwitchCommand, lock the protocol, but don't actually switch to the new protocol unless an acknowledgement is received. If an error is received, switch back.