CS型简单聊天室程序简介.ppt

CS型简单聊天室程序简介.ppt

ID:55827750

大小:981.00 KB

页数:25页

时间:2020-06-09

CS型简单聊天室程序简介.ppt_第1页
CS型简单聊天室程序简介.ppt_第2页
CS型简单聊天室程序简介.ppt_第3页
CS型简单聊天室程序简介.ppt_第4页
CS型简单聊天室程序简介.ppt_第5页
资源描述:

《CS型简单聊天室程序简介.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、C/S型简单聊天室程序简介2021/7/311展示内容程序设计Design2程序截图Screenshots4需求分析Requirement31程序实现Implementation332021/7/3121.需求分析Requirement功能性需求分析(FunctionalRequirements):1.Thereshouldbeaserverandatleastoneclient;2.Clientscouldsendmessageandeveryclientcouldreceivethemess

2、age;3.Serverallowsmultiuserstochatonlineatthesametime;4.Thecommunicationisinrealtimebetweenthemultipleclientsifany.非功能性需求分析(Non-functionalRequirements):1.Usejavasocketstocompletetheprogram;2.ThecommunicationshouldbeusingTCP.2021/7/313ClientB2.程序设计Des

3、ignClientAServerServer启动,建SocketClient请求与Server建立连接Client请求与Server建立连接Server接受Client请求Server接受Client请求Client向Server发送给所有Client的消息Server将Client发送的信息转发给所有已建立连接的ClientServer将Client发送的信息转发给所有已建立连接的ClientClient提出Close请求Client提出Close请求CloseClose2021/7/3142

4、.程序设计Design来呀我要连到聊天服务器嗯,进来了ClientAClientBServer–来宾AServer–来宾A,来宾BClientAServer–收到信息打铃了,上课了,大家快来啊…ClientAServer–信息分发给所有来宾ClientB打铃了,上课了,大家快来啊…1.客户端连接到服务器;2.服务器建立连接并把客户端驾到来宾清单中;3.另一个用户连接上来;4.用户A送出信息到聊天服务器上;5.服务器将信息送给所有来宾。Server,我要连上你了ClientAServer–等待用户

5、请求形象的描述O(∩_∩)O2.程序设计DesignPublicclassVerySimpleChatServer{…publicstaticvoidmain(String[]args){newVerySimpleChatServer().go();}publicvoidgo(){…try{while(true){Threadt=newThread(newClientHandler(clientSocket));t.start();}}}publicclassClientHandlerimple

6、mentsRunnable{…publicClientHandler(SocketclientSocket){…}publicvoidrun(){…try{…tellEveryone(message);…}}}publicvoidtellEveryone(Stringmessage){…}}2-1Server端代码框架2.程序设计DesignPublicclassSimpleChatClient{…publicstaticvoidmain(String[]args){client.go();}p

7、ublicvoidgo(){…sendButton.addActionListener(newSendButtonListener());setUpNetworking();ThreadreaderThread=newThreas(newIncomingReader());readerThread.start();}publicclassSendButtonListenerimplementsActionListener{…}publicvoidsetUpNetworking(){…}publi

8、cclassIncomingReaderimplementsRunnable{…}}2-2Client端代码框架3.程序实现ImplementationClientBClientAServerServer启动,建SocketClient请求与Server建立连接Client请求与Server建立连接Server接受Client请求Server接受Client请求Client向Server发送给所有Client的消息Server将Client发送的信息转发给所有已建立连接的ClientServer

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。