even though though although的区别(Geventsocketio documentation — geventsocketio 0.3.1 documentation)
Gevent-socketio documentation¶
Concepts¶
In order to understand the following documentation articles, let’s
clarify some of the terms used:A Namespace
is like a controller in the MVC world. It encompasses
a set of methods that are logically in it. For example, the
send_private_message event would be in the /chatnamespace, as
well as the kick_ban event. Whereas the scan_filesevent
would be in the /filesystemnamespace. Each namespace is
represented by a sub-class of BaseNamespace. A simple
example would be, on the client side (the browser):having loaded the socket.io.js
library somewhere in your .
On the server (this is a Pyramid example, but its pretty much the same
for other frameworks):Here we use socketio.socketio_manage()
to start the Socket.IO
machine, and handle the real-time communication.You will come across the notion of a Socket
. This is a virtual
socket, that abstracts the fact that some transports are long-polling
and others are stateful (like a Websocket), and exposes the same
functionality for all. You can have many namespaces inside a Socket,
each delimited by their name like /chat, /filesystemor
/foobar. Note also that there is a global namespace, identified
by an empty string. Some times, the global namespace has special
features, for backwards compatibilty reasons (we only have a global
namespace in version 0.6 of the protocol). For example, disconnecting
the global namespace means disconnect the full socket. Disconnecting
a qualified namespace, on the other hand, only removes access to that
namespace.The Socket
is responsible from taking the packets, which are, in
the realm of a Namespace or a Socketobject, a dictionary that
looks like:These packets are serialized in a compact form when its time to put
them on the wire. Socket.IO also has some optimizations if we need to
send many packets on some long-polling transports.At this point, if you don’t know gevent
, you probably will want to
learn a bit more about it, since it is the base you will be working
on:Getting started¶
Until we have a fully-fledged tutorial, please check out our example
applications and the API documentation.See this doc for different servers integration:
Examples¶
The gevent-socketio holds several examples:
https://github.com/abourget/gevent-socketio/tree/master/examples
chat.py is a bare-bone WSGI app with a minimal socketio integration
chatter2 is a simple chat application, showing off the minimal setup
chatter3 is an app using socket.io, backbone.js and redis for pubsub
chatter4 is chatter3 with persistence added.
testapp is the app we use to test the different features, so thereare a couple of more advanced use-cases demonstrated there
pyvore
is an application that was developed to serve as real-time
chat in conferences like the PyCon:This app is a Django tic-tac-toe application that uses the latest
gevent-socketio:API docs¶
https://github.com/abourget/gevent-socketio/tree/master/examples
chat.py is a bare-bone WSGI app with a minimal socketio integration
chatter2 is a simple chat application, showing off the minimal setup
chatter3 is an app using socket.io, backbone.js and redis for pubsub
chatter4 is chatter3 with persistence added.
testapp is the app we use to test the different features, so thereare a couple of more advanced use-cases demonstrated there
创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!