-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example of an Async API compatible protocol #21
Comments
|
I'm thinking about using JSONRPC as the reference protocol here. Motivation:
|
|
I like a line based (\r\n terminated) chat server better because you can quite easily demonstrate essential facets:
Examples used in core python socket module is here: https://babbledrive.appspot.com/static/doc/python-2.7.1/library/socket.html#example |
|
Okay. That's a good argument. I like the idea of having |
|
|
|
I'd vote for |
|
I actually prefer a generic class FrameProtocol(Protocol):
def __init__(self, parser, onFrame, onConnectionLost):
self._parser = parser
self._onFrame = onFrame
self._onConnectionLost = onConnectionLost
def connectionLost(self, reason):
self._onConnectionLost(reason)
def dataReceived(self, data):
self._parser.add(data)
for frame in iter(self._parser.get, self._parser.sentinel):
self.frameReceived(frame)
def frameReceived(self, frame):
self._onFrame(frame)
def send(self, frame):
self.transport.write(frame.compile()) |
Needs to use:
This should then ideally work on the stdlib implementation of the Async API backend, of course.
The text was updated successfully, but these errors were encountered: