📄 serverthreadforclient.java
字号:
{
r=r+服务器界面.clientOnlineList.GetMember(i).GetNumber()+"|";
}*/
}
}
if(Information.startsWith("1"))//发送给其他聊天者的消息格式为1
{
String To=Information.substring(1,10);
String From=Information.substring(10,19);
String Message=Information.substring(19);
new DMLMessageRecord(From,To,Message).Insert();
System.out.println("消息:"+Message);
Socket ToSocket=null;
String SMessage="1"+From+Message;
int i=0;
for(i=0;i<服务器界面.clientOnlineList.GetLength();i++){
if(服务器界面.clientOnlineList.GetMember(i).GetNumber().equals(To)){
ToSocket=服务器界面.clientOnlineList.GetMember(i).GetSocket();
}
}
if(ToSocket!=null){
Out=new PrintWriter(ToSocket.getOutputStream());
Out.println(new String(new StringBuffer(SMessage)));
Out.flush();
}
else{
new UpdatePersonalInformation(To,"LeavingInformation",SMessage.substring(1)).Update();
}
}
if(Information.startsWith("2"))//个人信息的修改
{
String PersonalInformation=Information.substring(1);
StringTokenizer St=new StringTokenizer(PersonalInformation,"|");
QQNumber=St.nextToken();
NickName=St.nextToken();
TrueName=St.nextToken();
Age=St.nextToken();
Sex=St.nextToken();
Icon=St.nextToken();
Sign=St.nextToken();
UpdatePersonalInformation Update=new UpdatePersonalInformation(QQNumber,NickName,TrueName,Sex,Age,Icon,Sign);
if(Update.UpdatePersonalInfo())
{
String r="4T";
Out=new PrintWriter(clientSocket.getOutputStream());
Out.println(new String(new StringBuffer(r)));
Out.flush();
}
else
{
String r="4F";
Out=new PrintWriter(clientSocket.getOutputStream());
Out.println(new String(new StringBuffer(r)));
Out.flush();
}
}
if(Information.startsWith("3"))//登录密码的修改的信息格式为3
{
QQNumber=Information.substring(1,10);
QQPassword=Information.substring(10);
UpdatePersonalInformation Update=new UpdatePersonalInformation(QQNumber,QQPassword);
if(Update.Update())
{
String r="PassT";
Out=new PrintWriter(clientSocket.getOutputStream());
Out.println(new String(new StringBuffer(r)));
Out.flush();
}
else
{
String r="PassF";
Out=new PrintWriter(clientSocket.getOutputStream());
Out.println(new String(new StringBuffer(r)));
Out.flush();
}
}
if(Information.startsWith("4"))//注册申请信息
{
String PersonalInformation=Information.substring(1);
System.out.println(PersonalInformation);
try{
StringTokenizer St=new StringTokenizer(PersonalInformation,"|");
QQNumber=St.nextToken();
//System.out.println(QQNumber);
QQPassword=St.nextToken();
//System.out.println(QQPassword);
NickName=St.nextToken();
//System.out.println(NickName);
TrueName=St.nextToken();
//System.out.println(TrueName);
Sex=St.nextToken();
//System.out.println(Sex);
Age=St.nextToken();
//System.out.println(Age);
LeavingInformation="@";
Icon=St.nextToken();
//System.out.println(Icon);
Sign=St.nextToken();
FriendList=Icon+QQNumber+NickName+"#";
OnlineTime="@";
RequestList="@";
ResponseList="@";
GroupList="@";
MyGroup="@";
Message="@";
GroupLeavingMessage="@";
UpdatePersonalInformation Insert=new UpdatePersonalInformation(QQNumber,QQPassword,NickName,TrueName,Sex,Age,LeavingInformation,Icon,Sign,FriendList,OnlineTime,RequestList,ResponseList,GroupList,MyGroup,Message,GroupLeavingMessage);
if(Insert.Insert())
{
String r="T";
Out=new PrintWriter(clientSocket.getOutputStream());
Out.println(new String(new StringBuffer(r)));
Out.flush();
}
else
{
String r="F";
Out=new PrintWriter(clientSocket.getOutputStream());
Out.println(new String(new StringBuffer(r)));
Out.flush();
}
}catch(NoSuchElementException e){
String r="F0";
Out=new PrintWriter(clientSocket.getOutputStream());
Out.println(new String(new StringBuffer(r)));
Out.flush();
}
}
if(Information.startsWith("5")){ //下线通知
String WhoLeave=Information.substring(1);
服务器界面.clientOnlineList.RemoveMember(QQNumber);
try {
QueryInformation LeaverInfor=new QueryInformation(WhoLeave);
String FriendList=LeaverInfor.GetFriendList();
UpdateOnlineListOff(FriendList);
try {
clientSocket.close();
} catch (IOException ex) {
ex.printStackTrace();
}
break;
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
if(Information.startsWith("6")){ //上线通知
try {
if(Identify.IsNumberExistOnline()){
IsHide=false;
}
else{
服务器界面.clientOnlineList.AddNewMember(QQNumber,IsHide,clientSocket);
System.out.println("天家");
}
QueryInformation PersonalInformation=new QueryInformation(QQNumber);
String s=PersonalInformation.GetFriendList();
UpdateOnlineListOn(s);//告诉我所有的好友我上线了
} catch (SQLException ex) {
ex.printStackTrace();
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
}
if(Information.startsWith("7")){ //隐身
IsHide=true;
QueryInformation PersonalInformation;
try {
PersonalInformation = new QueryInformation(QQNumber);
String s=PersonalInformation.GetFriendList();
UpdateOnlineListOff(s);//告诉我所有的好友我隐身了
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
if(Information.startsWith("8")){
int i=0;
String r="3";
for(i=0;i<服务器界面.Length;i++){
r=r+服务器界面.ClientList[i]+"|";
}
Out=new PrintWriter(clientSocket.getOutputStream());
Out.println(new String(new StringBuffer(r)));
Out.flush();
}
if(Information.startsWith("RequestGroupMember")){
String Number=Information.substring(18);
String Member=new DMLGroups().Query(Number,"Members");
String r="ReplyToRequestGroupMember";
new SendAndReceive(clientSocket,r+Member).SendMessage();
}
if(Information.equals("DelLevMsg")){ //看完留言后删除数据库中的数据
new UpdatePersonalInformation(QQNumber,"LeavingInformation","@").Update();
System.out.println("哈哈");
}
if(Information.equals("DelAddMsg")){ //接收完加好友请求后删除数据库中的数据
new UpdatePersonalInformation(QQNumber,"RequestList","@").Update();
System.out.println("再次哈哈");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -