I am trying to chat with django-socketio in my django application.
First, I need to learn about django-socketio, so I read the README https://github.com/stephenmcd/django-socketio
I really want to get the foundation for this. Therefore, I am trying to create a simple thing where the message will be transmitted through socketio.
My .py events:
@events.on_connect def first_connect(request, socket, context): socket.broadcast_channel("my message")
My opinion:
def chat(request): return render_to_response('chat.html', {} ,context_instance=RequestContext(request))
My URL:
url(r'^chat/$', 'projet.views.chat'),
My html:
<head> {% load socketio_tags %} {% socketio %} <script> var socket = new.io.Socket(); socket.connect(); socket.on('connect', function(){ socket.subscribe('my_channel'); }); </script> </head>
When I switch to localhost: 8000 / chat, nothing is displayed.
So this is probably very simple, but how can I just send a message through my socket and display it in my html when I connect to it?
I really want to know about this, so if anyone has a tutorial about django-sockieto, I would really appreciate it.
source share