当前位置:网站首页>109. 简易聊天室12:实现客户端一对一聊天
109. 简易聊天室12:实现客户端一对一聊天
2022-06-28 04:15:00 【Jasonakeke】
题目描述
题目实现:不同的客户端之间需要进行通信,一个客户端与指定的另一客户端进行通信,实现一对一聊天功能。
实现一个客户端与指定的另一客户端进行通信,运行程序,服务器启动后,启动3个客户端程序,分别以小小,虚虚,竹竹,登录 ,然后在左侧的用户列表中选择接收信息用户,输入聊天信息,发送到目标用户。
解题思路
创建一个服务类:ClientOneToOneServerFrame,继承JFrame类
定义ServerThread线程类,用于为客户端添加用户列表。有一部分代码用于转发客户端发送的消息。
创建一个客户端类:ClientOneToOneClientFrame,继承JFrame类
定义ClientThread线程类,用于对接收到服务器的信息,进行处理。如果是登录用户,就添加到用户列表中。
如果是消息,就追加到文本域中。
技术重点:
在服务器端通过线程对客户端发送的信息进行监听,并对登录用户和消息分别进行处理。如果是登录用户,就将所有用户添加到客户端的用户列表中;如果是消息,就转发给指定的用户;客户端则通过线程对接收到的信息进行处理,
边栏推荐
- 【Proteus仿真】定时器1外部计数中断
- Is the securities account opened by qiniu safe? How to open an account
- Difference between curdate() and now()
- [early knowledge of activities] list of recent activities of livevideostack
- Meta universe standard forum established
- Precautions for using C language global variables (global variables in C and H files, static global variables)
- Role of native keyword
- 几百行代码实现一个脚本解释器
- Oracledata installation problems
- Analysis of distributed transaction TCC
猜你喜欢

阿里P8倾情推荐,Fiddler抓包工具实战篇(一)

CUPTI error: CUPTI could not be loaded or symbol could not be found.

How do I get the STW (pause) time of a GC (garbage collector)?

How to traverse collections Ordereddict, taking it and forgetting items

Why are cloud vendors targeting this KPI?

Google Earth engine (GEE) - global flood database V1 (2000-2018)

?位置怎么写才能输出true

Idle interrupt cannot be cleared

Necessary skills for test and development: actual combat of security test vulnerability shooting range

Matlab exercises -- basic data processing
随机推荐
The coming wave of Web3
玩转双指针
Google Earth Engine(GEE)——全球洪水数据库 v1 (2000-2018年)
?位置怎么写才能输出true
S32ds jump to defaultisr
一文详解|增长那些事儿
Principle of event delegation
Moonbeam集成Coin98,给予用户在多链道路上的更多选择
June 27, 2022: give a 01 string with a length of N. now please find two intervals so that the number of 1 and the number of 0 in the two intervals are equal. The two intervals can intersect, but not c
[noip2002 popularization group] cross the river pawn
多线程实现 重写run(),怎么注入使用mapper文件操作数据库
Precautions for using C language global variables (global variables in C and H files, static global variables)
mysql----where 1=1是什么意思
CUPTI error: CUPTI could not be loaded or symbol could not be found.
A bit of knowledge - online resources on Chinese Learning
Huawei's 9-year experience as a software testing director
快速下载JDK,除了官方Oracle下载,还有国内可以有最新版本的下载地址吗
Aspnetcoreratelimit rate limit interface access limit current limit control
2022年中国音频市场年度综合分析
Tiktok actual battle ~ take off the blogger