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

代碼片段和文件信息
package?bean;
import?org.apache.commons.codec.DecoderException;
import?util.BasicUtils;
/**
?*?消息協議格式:
?*?包序號+命令字+用戶名+‘:‘+主機名+‘:‘+消息正文
?*?包序號:占8Byte,采用當前毫秒數轉換為字節數組,這也是包的發送時間
?*?命令字:即head字段,是長度為2的字符串;每個命令字在Global類中定義
?*?@author?DELL
?*
?*/
public?class?Message?{
private?long?seq;?//包序號
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(“====發送消息:“+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;
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????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個文件信息
評論
共有 條評論