Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60286
| Date | 2013-11-23 01:27 -0800 |
|---|---|
| From | Padawan Learner <newb@seehart.com> |
| Subject | Simple TCP message framework |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3077.1385198997.18130.python-list@python.org> (permalink) |
Seems like the following pattern must be very common, solved a million
times, but I can't seem to find anything this simple and ready to use.
Basically I just want a simple python messaging layer that hides some of
the messiness of the underlying sockets and user authentication. It
would be asyncore under the hood of course.
Perhaps what I am looking for is hiding in plain sight, but there are so
many asynchronous communication tools out there, it's hard to thumb
through them all. So I'm not looking for such a list of toolkits to
browse through. Just something simple that does the equivalent of the
following:
Server:
on_open(user) - called when a user logs in
on_close(user) - called when a user disconnects
on_recv(user, s) - called when a user sends a message
send(user, s) - send a message to a user
Client:
open(host, user, password) - open an authenticated session with the
host
close() - disconnect
send(s) - send a message to the server
on_recv(s): called when a message is received from the server
Methods starting with "on_" are callbacks intended to be implemented by
derived classes.
Messages are atomic and delimited by '\n'. So concatenation of buffered
messages is hidden. A message is received when complete (i.e. terminated
with '\n'). Also, each message should be implicitly flushed, so that it
will be received in a timely manner in the absence of additional messages.
Extra bonus for a compatible javascript implementation of the Client as
well, so it can run in a browser.
Thanks in advance for any thoughts.
- Padawan
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Simple TCP message framework Padawan Learner <newb@seehart.com> - 2013-11-23 01:27 -0800
csiph-web