<div dir="ltr"><div><div><div><div>Hi everyone,<br><br><br>I think I've hit one of those cases where AMP really seems to want everything (locator, receiver, sender) to be an instance of t.p.amp.AMP :-(<br><br></div>I've written some code that tries to multiplex stream transports over AMP:<br>

<br><a href="https://github.com/lvh/txampext/blob/multiplexing/txampext/multiplexing.py">https://github.com/lvh/txampext/blob/multiplexing/txampext/multiplexing.py</a><br><br></div>The repo contains an example server and client, which demonstrate the issue:<br>

<br><a href="https://github.com/lvh/txampext/blob/multiplexing/docs/examples/multiplexing_client.py">https://github.com/lvh/txampext/blob/multiplexing/docs/examples/multiplexing_client.py</a><br><a href="https://github.com/lvh/txampext/blob/multiplexing/docs/examples/multiplexing_server.py">https://github.com/lvh/txampext/blob/multiplexing/docs/examples/multiplexing_server.py</a><br>

<br></div>In order to do some of this multiplexing, I need access to the protocol instance inside the responder on the server side. Fortunately, I already had some code that exposed box senders (after a lot of advice from Glyph). I modified it to expose the protocol as well:<br>

<br><a href="https://github.com/lvh/txampext/blob/multiplexing/txampext/exposed.py#L41">https://github.com/lvh/txampext/blob/multiplexing/txampext/exposed.py#L41</a><br><br></div>However, it turns out fromBox gets called with the *responder locator* as the "proto" argument, not the actual protocol.<br>

<div><div><br></div><div>The server has a pudb call that makes it easy (?!) to trace this down. The CommandLocator class, inside doit (a function defined in _wrapWithSerialization) passes "self" to command.parseArguments:<br>

<br><a href="https://twistedmatrix.com/trac/browser/trunk/twisted/protocols/amp.py#L1015">https://twistedmatrix.com/trac/browser/trunk/twisted/protocols/amp.py#L1015</a><br><br></div><div>This is the part where I think the contract is broken, since parseArguments claims to want the protocol (well, it says it wants the AMP protocol, which, subclassing everything, is also all of the things, of course), but receives the responder locator.<br>

<br></div><div>What am I doing wrong? Is this a bug?<br><br></div><div>confusedly,<br>lvh<br></div></div></div>