Creating real-time chat with Python and websocket

I am writing a python real-time chat function built into a web application. I am a bit confused about real-time implementation. I need to click messages in real time for different users.

I plan to use websocket, but I'm not quite sure how to store these sockets in an array so that after a user sends a message to the server, the server can find the corresponding socket and click the message.

Do you know about this? Or what is the general way to implement the live chat feature?

Thanks in advance.

+5
source share
1 answer

You need to use a web server with web socket support, such as Tornado, to handle web socket traffic. There are solutions for multiplexing chat messages between different chats and users, such as Redis and ZeroMQ, which can be used to multiplex messages.

However, it looks like you have zero experience and a starting point, so it's best to start with a working example. Please examine existing real-time chat implementations for Python:

https://github.com/heroku-examples/python-websockets-chat

https://github.com/nellessen/Tornado-Redis-Chat

https://github.com/tornadoweb/tornado/blob/master/demos/websocket/chatdemo.py

http://ferretfarmer.net/2013/09/05/tutorial-real-time-chat-with-django-twisted-and-websockets-part-1/

+10
source

All Articles