I do chat on https://ferretfarmer.net/2013/09/05/tutorial-real-time-chat-with-django-twisted-and-websockets-part-2/ to this manual, In the LineReceiver you need to get the session id from GET attribute ws: // localhost: 8000? / ws / session_id = abc123. How to implement it? Now the code is what I represented it:

class MyChat(basic.LineReceiver): def connectionMade(self): print "New client: {0}".format(self) print self.kwargs['session_id'] self.factory.clients.append(self) 
  • Please, update, the link - the other part - Vassily Vorobyov
  • the manual seems to use an abandoned patch (4+ years) that was not added in twisted. Information on request parameters in MyChat not available. Look in the source code where request is available (at the level of: WebSocketsResource.render and lookupProtocolForFactory.lookupProtocol ). Autobahn looks like a more current WebSocket implementation for Twisted. - jfs
  • Can you tell me how to connect it to django? - Vassily Vorobyov
  • these are independent things. Django is a WSGI application (synchronous model), and autobahn runs on asynchronous libraries such as twisted, asyncio. How to connect them depends on the project, for example, django can publish events using http POST to the address provided by the asynchronous party (twisted), which already using the web socket can deliver the event to clients. I don’t know which django libraries are used to make friends with the web socket. - jfs

0