Home  >  Article  >  Backend Development  >  How to build a point-to-point chat function with swoole+websocket

How to build a point-to-point chat function with swoole+websocket

WBOY
WBOYOriginal
2016-08-04 09:19:221202browse

If the customer service staff is logged in, it will be displayed on the page that the customer service is online. After the customer logs in, they can choose a customer service for consultation

No matter customer service or users, they can be reconnected and matched by refreshing the page.

I’m new to swoole and I’m not familiar with it. My first instinct is to find a way to save the current ws connection id and user_id to redis when logging in. Rebind this relationship when refreshing the page. When sending a message, bring the corresponding user_id to the background. Find the connection ID and send the information! !

I don’t know if this is reasonable or not. I don’t have a deep understanding of it yet. Please give me some guidance. Thank you very much!

Reply content:

If the customer service staff is logged in, it will be displayed on the page that the customer service is online. After the customer logs in, they can choose a customer service for consultation

No matter customer service or users, they can be reconnected and matched by refreshing the page.

I am new to swoole and I am not familiar with it. My first instinct is to find a way to save the current ws connection id and user_id to redis when logging in. When refreshing the page, rebind this relationship. When sending a message, bring the corresponding user_id to the background. Find the connection ID and send the information! !

I don’t know if this is reasonable or not. I don’t have a deep understanding of it yet. Please give me some guidance. Thank you very much!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn