Closed rajasimon closed 9 years ago
Hi
I just installed everything django-socketio asks now my code is:
result.html
<script type="text/javascript"> var socket = new io.Socket(); socket.connect(); socket.on('connect', function() { socket.subscribe('my channel'); }); socket.on('event', function(data){ console.log(data); }); socket.on('disconnect', function(){ // alert('Disconnectded'); }) </script>
Views
def result(request): return render(request, 'result.html') import django_socketio as socket def publish_result(request): socket.broadcast_channel('my message here', channel='my channel') return HttpResponse("Yes published")
Ok then
when I hit the publish_result url my message will sent to my channel right ? then why console.log(data) always empty ?
publish_result
console.log(data)
Is my method and logic correct..? Please guide me here
https://github.com/stephenmcd/django-socketio/blob/master/django_socketio/example_project/chat/static/js/chat.js#L107
Hi
I just installed everything django-socketio asks now my code is:
result.html
Views
Ok then
when I hit the
publish_result
url my message will sent to my channel right ? then whyconsole.log(data)
always empty ?Is my method and logic correct..? Please guide me here