当前位置:网站首页>109. 简易聊天室12:实现客户端一对一聊天
109. 简易聊天室12:实现客户端一对一聊天
2022-06-28 04:15:00 【Jasonakeke】
题目描述
题目实现:不同的客户端之间需要进行通信,一个客户端与指定的另一客户端进行通信,实现一对一聊天功能。
实现一个客户端与指定的另一客户端进行通信,运行程序,服务器启动后,启动3个客户端程序,分别以小小,虚虚,竹竹,登录 ,然后在左侧的用户列表中选择接收信息用户,输入聊天信息,发送到目标用户。
解题思路
创建一个服务类:ClientOneToOneServerFrame,继承JFrame类
定义ServerThread线程类,用于为客户端添加用户列表。有一部分代码用于转发客户端发送的消息。
创建一个客户端类:ClientOneToOneClientFrame,继承JFrame类
定义ClientThread线程类,用于对接收到服务器的信息,进行处理。如果是登录用户,就添加到用户列表中。
如果是消息,就追加到文本域中。
技术重点:
在服务器端通过线程对客户端发送的信息进行监听,并对登录用户和消息分别进行处理。如果是登录用户,就将所有用户添加到客户端的用户列表中;如果是消息,就转发给指定的用户;客户端则通过线程对接收到的信息进行处理,
边栏推荐
- Why are cloud vendors targeting this KPI?
- How to traverse collections Ordereddict, taking it and forgetting items
- Detailed reading of the thesis: implementing volume models for handowriting text recognition
- 一文详解|增长那些事儿
- JVM I: introduction to JVM and understanding of class files
- 100+ data science interview questions and answers Summary - machine learning and deep learning
- The development of the Internet has promoted the emergence of a series of new models such as unbounded retail, digital retail and instant retail
- Design a stack with getmin function
- The SQL of filincdc always reports this error when there are multiple tables. How can I solve it
- Moonbeam集成Coin98,给予用户在多链道路上的更多选择
猜你喜欢

政策利好,20多省市开启元宇宙发展规划

A doctor's 22 years in Huawei (full of dry goods)

Sword finger offer 49 Ugly number (three finger needling technique)

The company leader said that if the personal code exceeds 10 bugs, he will be dismissed. What is the experience?

How to traverse collections Ordereddict, taking it and forgetting items
![[applet] solution document using font awesome Font Icon (picture and text)](/img/1b/d1b738e6e35e59cc4a417df4ea0e8d.png)
[applet] solution document using font awesome Font Icon (picture and text)

Audio and video technology development weekly

With the transformation of automatic empowerment, Feihe dairy accelerates its move towards digitalization!
![[matlab traffic light identification] traffic light identification [including GUI source code 1908]](/img/0e/3103c4c5dd664196c85db9b30bcaf5.png)
[matlab traffic light identification] traffic light identification [including GUI source code 1908]

Severe tire damage: the first rock band in the world to broadcast live on the Internet
随机推荐
Database garbled
xml  File read / write
Excel knowledge and skills summary
Establishment of SSH Framework (Part 2)
Aspnetcoreratelimit rate limit interface access limit current limit control
Games104 operation 2-colorgrading
27 years, Microsoft IE is over!
知识点滴 - 关于汉语学习的网络资源
Analysis of distributed transaction TCC
Moonbeam集成Coin98,给予用户在多链道路上的更多选择
Source code of live video system, countdown display, countdown of commodity spike
Is it better for a novice to open a securities account? Is it safe to open a stock account
Code understanding: implementing volume models for hangwriten text recognition
Is it true that qiniu business school gives away securities accounts? Is it safe to open an account
Multithreading and high concurrency III: AQS underlying source code analysis and implementation classes
[matlab traffic light identification] traffic light identification [including GUI source code 1908]
PHP code wechat, official account and enterprise wechat send emoticons [u+1f449]
一文详解|增长那些事儿
2022年中国音频市场年度综合分析
穿越封锁的最新利器,速度最快梯没有之一。