欢迎来到天天文库
浏览记录
ID:10544612
大小:364.00 KB
页数:45页
时间:2018-07-07
《局域网聊天系统代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Server代码Bean类packageServer;importjava.net.Socket;importjava.io.Serializable;importjava.util.HashMap;importjava.util.HashSet;publicclassBeanimplementsSerializable{privateinttype;//1私聊0上下线更新-1下线请求2请求发送文件3.确定接收文件privateHashSetclients;//存放选中的客户privateHashSet2、tring>to;publicHashMaponlines;privateStringinfo;privateStringtimer;privateStringname;privateStringfileName;privateintsize;privateStringip;privateintport;publicintgetType(){returntype;}publicvoidsetType(inttype){this.type=type;}publicHashSetget3、Clients(){returnclients;}publicvoidsetClients(HashSetclients){this.clients=clients;}publicHashSetgetTo(){returnto;}publicvoidsetTo(HashSetto){this.to=to;}publicHashMapgetOnlines(){returnonlines;}publicvoidsetOnlines(HashMap4、ing,Bean>onlines){this.onlines=onlines;}publicStringgetInfo(){returninfo;}publicvoidsetInfo(Stringinfo){this.info=info;}publicStringgetTimer(){returntimer;}publicvoidsetTimer(Stringtimer){this.timer=timer;}publicStringgetName(){returnname;}publicvoidsetName(String5、name){this.name=name;}publicStringgetFileName(){returnfileName;}publicvoidsetFileName(StringfileName){this.fileName=fileName;}publicintgetSize(){returnsize;}publicvoidsetSize(intsize){this.size=size;}publicStringgetIp(){returnip;}publicvoidsetIp(Stringip){this.ip=6、ip;}publicintgetPort(){returnport;}publicvoidsetPort(intport){this.port=port;}}Clientbean类packageServer;importjava.net.Socket;publicclassClientBean{privateStringname;privateSocketsocket;publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.name=name7、;}publicSocketgetSocket(){returnsocket;}publicvoidsetSocket(Socketsocket){this.socket=socket;}}Server类packageServer;importjava.io.*;importjava.net.*;importjava.util.*;importClient.Bean;importClient.ClientBean;publicclassServer{privatestaticServerSocketss;publicsta8、ticHashMaponlines;static{try{ss=newServerSocket(8520);onlines=newHashMap();}catch(IOExceptione){//TODOAuto-generat
2、tring>to;publicHashMaponlines;privateStringinfo;privateStringtimer;privateStringname;privateStringfileName;privateintsize;privateStringip;privateintport;publicintgetType(){returntype;}publicvoidsetType(inttype){this.type=type;}publicHashSetget
3、Clients(){returnclients;}publicvoidsetClients(HashSetclients){this.clients=clients;}publicHashSetgetTo(){returnto;}publicvoidsetTo(HashSetto){this.to=to;}publicHashMapgetOnlines(){returnonlines;}publicvoidsetOnlines(HashMap4、ing,Bean>onlines){this.onlines=onlines;}publicStringgetInfo(){returninfo;}publicvoidsetInfo(Stringinfo){this.info=info;}publicStringgetTimer(){returntimer;}publicvoidsetTimer(Stringtimer){this.timer=timer;}publicStringgetName(){returnname;}publicvoidsetName(String5、name){this.name=name;}publicStringgetFileName(){returnfileName;}publicvoidsetFileName(StringfileName){this.fileName=fileName;}publicintgetSize(){returnsize;}publicvoidsetSize(intsize){this.size=size;}publicStringgetIp(){returnip;}publicvoidsetIp(Stringip){this.ip=6、ip;}publicintgetPort(){returnport;}publicvoidsetPort(intport){this.port=port;}}Clientbean类packageServer;importjava.net.Socket;publicclassClientBean{privateStringname;privateSocketsocket;publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.name=name7、;}publicSocketgetSocket(){returnsocket;}publicvoidsetSocket(Socketsocket){this.socket=socket;}}Server类packageServer;importjava.io.*;importjava.net.*;importjava.util.*;importClient.Bean;importClient.ClientBean;publicclassServer{privatestaticServerSocketss;publicsta8、ticHashMaponlines;static{try{ss=newServerSocket(8520);onlines=newHashMap();}catch(IOExceptione){//TODOAuto-generat
4、ing,Bean>onlines){this.onlines=onlines;}publicStringgetInfo(){returninfo;}publicvoidsetInfo(Stringinfo){this.info=info;}publicStringgetTimer(){returntimer;}publicvoidsetTimer(Stringtimer){this.timer=timer;}publicStringgetName(){returnname;}publicvoidsetName(String
5、name){this.name=name;}publicStringgetFileName(){returnfileName;}publicvoidsetFileName(StringfileName){this.fileName=fileName;}publicintgetSize(){returnsize;}publicvoidsetSize(intsize){this.size=size;}publicStringgetIp(){returnip;}publicvoidsetIp(Stringip){this.ip=
6、ip;}publicintgetPort(){returnport;}publicvoidsetPort(intport){this.port=port;}}Clientbean类packageServer;importjava.net.Socket;publicclassClientBean{privateStringname;privateSocketsocket;publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.name=name
7、;}publicSocketgetSocket(){returnsocket;}publicvoidsetSocket(Socketsocket){this.socket=socket;}}Server类packageServer;importjava.io.*;importjava.net.*;importjava.util.*;importClient.Bean;importClient.ClientBean;publicclassServer{privatestaticServerSocketss;publicsta
8、ticHashMaponlines;static{try{ss=newServerSocket(8520);onlines=newHashMap();}catch(IOExceptione){//TODOAuto-generat
此文档下载收益归作者所有