摘 要
在科学技术日新月异发展的今天,信息的快速获取、发布和传递扮演的角色更加重要,网络聊天则成为人们信息交换工具的首选,它以其快速便捷、大容量存储的优势占据着信息传输的重要位置.随着人们生活品质的提高,在网络聊天的同时,人们也越来越注重过程娱乐性的享受,开始追求一种更加有趣的聊天方式来为枯燥乏味的生活增添光彩.
网络技术层出不穷,而本论文是以Eclipse作为编程环境,Java为开发语言,使用Socket编程接口实现基于TCP协议的服务器和客户端程序.该聊天程序以动漫风格的黑白色调为主,适用于局域网内多人聊天,实现了发布信息的检索与过滤,辅以趣味性功能,营造了一个和谐生动的聊天氛围.
该聊天程序服务器采用多线程多任务的设计思想,主要包含服务器管理及用户信息管理两部分,服务器日记可通过文本进行保存,实现了发送系统消息及强制解除在线用户的功能;客户端通过对数据流的合理设计,可以进行信息传递、接收和信息保存以及其他趣味性功能.
用户只需要注册登录到聊天室即可参与会话,同时为了降低聊天过程的枯燥性,一方面在界面上采用了图形的动态显示,以黑白色调为基准,增加了文字字体、大小、颜色的实时调整,此外,动态表情的切换和自定义文字气泡框是趣味性的最大体现,辅以用户当前在线时间显示和音乐播放效果使得该聊天器实用性更强.该程序以最简单而有效的方式处理用户请求,动态实时完成信息的交换,具有很强的交互性和扩展性.
关键词:网络聊天;Socket;趣味性;动漫风格;
ABSTRACT
Nowadays, the distribution and transmission of information plays a more and more important role. Especially with the rapid development of science and technology, network chat has become the first choice for information-exchanging. The advantage of its convenience and large-capacity storage occupies a crucial position in information transmission. Since people’s quality of life has improved,they pay more attention to entertainment when they enjoy the chatting process. A willing to pursue a more interesting chat mode to add luster to the boring life.
Network technology emerges endlessly. And this design which is based on Java language makes use of Socket programming interface and Transmission Control Protocol to implement a server and clients. The black-white cartoonish style belongs to the talker which is suitable for multi-user chatting within the local area network (LAN). Meanwhile, it builds a harmonious and interesting atmosphere through making a difference in information retrieval and filtering.
By adopting multi-thread and multi-tasks programming technique, the server in this talker mainly contains server management and user information management. It satisfies the function of sending system message and updating online users. Besides, the server diary can be saved by text. When it comes to the client, the reasonable design of data stream has a great impact on information transmission, receiving ,saving and interesting function.
Users only need to login and register the talker to join the dialog. What’s more, for lightening this talker, dynamic graphics are displayed on the interface. The real-time adjustment of the text font, size and color is also flexible in order to increase fun. Expression switching and text balloons are the greatest point of interest. In addition,time-displaying and music-playing are also available. Talker has an access to handling users’ requests through the most simple and effective way. It exchanges information dynamically, blessed with strong interactivity and scalability.
Keywords: Network chat; Socket; Fun;cartoonish style
目 录
第1章 绪论 1
1.1 引言 1
1.2 聊天器开发背景 1
1.3 国内外聊天器优劣势对比 1
1.4 课题工作综述 2
1.5 论文框架结构 2
第2章 系统分析与设计 3
2.1 需求分析 3
2.2 可行性分析 3
2.3 系统设计 4
2.3.1 服务器设计 4
2.3.2 客户端设计 4
2.3.3 综合设计 5
2.4 技术手段 6
2.4.1 Java语言的选择 6
2.4.2 Eclipse开发工具的应用 8
2.4.3 TCP/IP协议 8
2.4.4 端口号 9
2.4.5 套接字建立 9
2.4.6 多线程应用 10
第3章 聊天器实现 13
3.1 服务器实现 13
3.1.1 服务器概述 13
3.1.2 服务器功能实现 14
3.2 客户端实现 16
3.2.1 用户注册 16
3.3.2 用户登入 19
3.3.3 聊天模式 21
3.3.3 文字设置 23
3.3.4 动态表情切换 24
3.3.5 自定义文字气泡框 24
3.3.6 简单音乐播放器 25
3.3.7 当前时间显示 25
3.3.8 关键字、清屏及记录保存 26
第4章 系统测试 29
4.1 模块测试 29
4.1.1 注册模块 29
4.1.2 登入模块 30
4.1.3 聊天模块 30
4.2 综合测试 32
第5章 结论与展望 35
5.1 结论 35
5.1.1 程序创新性 35
5.1.2 感想与体会 35
5.2 不足之处及未来展望 35
参考文献 37
致 谢 39