django-socket-server
Django Socket Server
Quickstart
Install django-socket-server:
pip install django-socket-server
Add socket_server to INSTALLED_APPS:
INSTALLED_APPS = ( ... 'socket_server', ... )
Create a sockets.py in an application of your project.
django-socket-server will discover the socket files that are in applications installed against Django.
An example sockets.py looks like this:
from socket_server.namespace import EventNamespace
class Namespace(EventNamespace):
def client_connected(self, client):
super(Namespace, self).client_connected(client)
print 'Send ping'
self.emit_to(client, 'ping')
def register_callbacks(self):
return {
'pong': self.pong
}
def pong(self, client, **kwargs):
print 'Received pong event'
Messages are sent and received in JSON, and always contain an event key. This key is then mapped to callbacks, added inside register_callbacks.
You can specify a namespace name using the name property like so:
class Namespace(EventNamespace):
name = 'pingpong'
If you do not specify a name, the app name will be used by default.
Start Socket Server
Use the management command provided to start the socket server: python manage.py start_socket.
You may pass an optional –port to override the default port of 3000.
Client connection
The above example would expose the following: ws://localhost:3000/pingpong
Documentation
The full documentation is at https://django-socket-server.readthedocs.org.
Links
History
0.0.1 (2015-01-01)
First release on PyPI.
0.0.2 (2015-01-30)
Added python client classes
0.0.3 (2015-01-30)
Catch server shutdown and pass to namespaces
0.0.4 (2015-02-01)
Remove debugging and add “room” event errors
Metadata
Release files for django-socket-server 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-socket-server-0.0.4.tar.gz | 9.2 kB | Without provenance | Details for django-socket-server-0.0.4.tar.gz |
Release files / django-socket-server-0.0.4.tar.gz
| Download URL | django-socket-server-0.0.4.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f45f1c81941e8dfea534ff3d12197828dc956df196ae7934cc28df3cdeaeb694
|
|
BLAKE2b-256 checksum How to use checksums |
80b7d5ad68cc2c75583c4dbe64eb5bb90503d50ae81ef408fda9b231e7293785
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-socket-server 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.