資源簡(jiǎn)介
本資源是本人前面發(fā)過的一個(gè)局域網(wǎng)聊天工具的升級(jí)版。主要在界面上進(jìn)行了美化,并添加了語音聊天的功能。具體功能有:
1.采用了全新的界面風(fēng)格(新增)
2.實(shí)現(xiàn)了基本文字聊天功能
3.實(shí)現(xiàn)了基本文件傳送功能
4.實(shí)現(xiàn)了發(fā)送窗口抖動(dòng)的功能
5.實(shí)現(xiàn)了語音聊天的功能(新增)
資源內(nèi)容包括源程序和打包后的可執(zhí)行jar文件,以及要用到的所有jar包;
代碼保證可用,如有問題請(qǐng)留言,代碼較規(guī)范,結(jié)構(gòu)清晰,相信對(duì)學(xué)習(xí)java socket編程和swing界面開發(fā)的朋友有一定的幫助。
注:main函數(shù)在MainFrame類

代碼片段和文件信息
package?bean;
import?org.apache.commons.codec.DecoderException;
import?util.BasicUtils;
/**
?*?消息協(xié)議格式:
?*?包序號(hào)+命令字+用戶名+‘:‘+主機(jī)名+‘:‘+消息正文
?*?包序號(hào):占8Byte,采用當(dāng)前毫秒數(shù)轉(zhuǎn)換為字節(jié)數(shù)組,這也是包的發(fā)送時(shí)間
?*?命令字:即head字段,是長(zhǎng)度為2的字符串;每個(gè)命令字在Global類中定義
?*?@author?DELL
?*
?*/
public?class?Message?{
private?long?seq;?//包序號(hào)
private?String?userName;
private?String?hostName;
private?String?head;?//消息頭,表明消息的類型
private?String?data;?//消息正文
public?Message(){
}
public?Message(String?userNameString?hostNameString?head?String?message)?{
this.seq?=?System.currentTimeMillis();
this.head?=?head;
this.data?=?message;
this.hostName?=?hostName;
this.userName?=?userName;
System.out.println(“====發(fā)送消息:“+seq+this.head+this.userName+“:“+this.hostName+“:“+this.data);
}
public?Message(long?seq?String?userNameString?hostNameString?head?String?message)?{
this.seq?=?seq;
this.head?=?head;
this.data?=?message;
this.hostName?=?hostName;
this.userName?=?userName;
}
public?String?getHead()?{
return?head;
}
public?void?setHead(String?head)?{
this.head?=?head;
}
public?String?getData()?{
return?data;
}
public?void?setData(String?data)?{
this.data?=?data;
}
public?long?getSeq()?{
return?seq;
}
public?void?setSeq(long?seq)?{
this.seq?=?seq;
}
public?String?getUserName()?{
return?userName;
}
public?void?setUserName(String?userName)?{
this.userName?=?userName;
}
public?String?getHostName()?{
return?hostName;
}
public?void?setHostName(String?hostName)?{
this.hostName?=?hostName;
}
public?byte[]?toBytes()?throws?DecoderException{
byte[]?seqBytes?=?BasicUtils.longToByteArray(this.seq);
byte[]?otherBytes?=?(this.head+this.userName+“:“+this.hostName+“:“+this.data).getBytes();
byte[]?msgBytes?=?new?byte[seqBytes.length+otherBytes.length];
for(int?i=0;i if(i msgBytes[i]?=?seqBytes[i];
else
msgBytes[i]?=?otherBytes[i-seqBytes.length];
}
return?msgBytes;
}
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????417??2014-02-25?09:31??MyMessager2.1\.classpath
?????文件????????389??2014-02-23?16:26??MyMessager2.1\.project
?????文件????????598??2014-02-23?00:52??MyMessager2.1\.settings\org.eclipse.jdt.core.prefs
?????文件???????2822??2014-02-25?09:31??MyMessager2.1\bin\bean\Message.class
?????文件???????3192??2014-02-25?09:31??MyMessager2.1\bin\bean\TbMsg.class
?????文件???????1552??2014-02-25?09:31??MyMessager2.1\bin\bean\User.class
?????文件??????10240??2014-02-25?09:28??MyMessager2.1\bin\data\userdata.db
?????文件????????453??2014-02-25?09:31??MyMessager2.1\bin\exception\MessageOverflowException.class
?????文件???????8370??2014-02-25?09:31??MyMessager2.1\bin\handler\MessageReceiver.class
?????文件???????4564??2014-02-25?09:31??MyMessager2.1\bin\handler\MessageSender.class
?????文件???????3563??2014-02-25?09:31??MyMessager2.1\bin\handler\VoiceReceiver.class
?????文件???????3709??2014-02-25?09:31??MyMessager2.1\bin\handler\VoiceSender.class
?????文件??????25813??2014-02-21?23:38??MyMessager2.1\bin\images\1.jpg
?????文件??????86994??2014-02-21?23:51??MyMessager2.1\bin\images\2.jpg
?????文件????????781??2013-11-28?22:38??MyMessager2.1\bin\images\accept.png
?????文件????????652??2013-06-20?21:15??MyMessager2.1\bin\images\accepting.png
?????文件????????733??2013-11-28?22:22??MyMessager2.1\bin\images\add.png
?????文件???????2035??2014-02-22?16:10??MyMessager2.1\bin\images\app48.png
?????文件???????2942??2014-02-22?16:10??MyMessager2.1\bin\images\app64.png
?????文件????????733??2013-11-30?13:38??MyMessager2.1\bin\images\basket_put.png
?????文件????????738??2013-11-30?13:38??MyMessager2.1\bin\images\basket_remove.png
?????文件????????789??2013-11-28?17:33??MyMessager2.1\bin\images\bell.png
?????文件???????1308??2014-02-22?16:08??MyMessager2.1\bin\images\bell24.png
?????文件????????745??2013-11-28?17:34??MyMessager2.1\bin\images\book_go.png
?????文件????????773??2013-06-20?21:17??MyMessager2.1\bin\images\cancel.png
?????文件????????587??2013-11-28?23:18??MyMessager2.1\bin\images\cancel2.png
?????文件???????1124??2014-02-23?01:19??MyMessager2.1\bin\images\closemic24.png
?????文件????????781??2013-11-28?22:38??MyMessager2.1\bin\images\completed.png
?????文件???????1066??2013-06-18?18:36??MyMessager2.1\bin\images\computer.png
?????文件????????715??2013-11-28?22:23??MyMessager2.1\bin\images\delete.png
............此處省略136個(gè)文件信息
評(píng)論
共有 條評(píng)論