如何只按照添加客户端的顺序向其他客户端发送消息? [英] How to send messages to other clients only in the sequence of adding clients?

查看:72
本文介绍了如何只按照添加客户端的顺序向其他客户端发送消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

https://github.com/kakkarotssj/ChatApplication/blob/master/GroupChat/sever.py

https://github.com/kakkarotssj/ChatApplication/blob/master/GroupChat/client.py

当服务器启动时,假设添加了三个客户端.当第一个客户端尝试发送消息时,它会工作,类似的 client2 和 client3 但是当这个序列中断时会出现问题,比如假设客户端是按照 a、b 和 c 的顺序添加的,如果 b 或 c 尝试向其他人发送消息,那么奇怪的事情发生.我的猜测是 thread2 的目标函数,即 handle_messages 无法正常运行

When server starts, and suppose three clients got added. When first client try to send message, it will work and similarly client2 and client3 but problem occurs when this sequence breaks like suppose clients were added in the sequence of a, b and c and if b or c tries to send message to others, something weird happens. My guess is target function of thread2, i.e handle_messages isn't functioning properly

推荐答案

改变创建线程的方式,解决了这个问题.

Change in approach of creating thread, resolves this issue.

这篇关于如何只按照添加客户端的顺序向其他客户端发送消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆