|
java网络五子棋的源代码(36) } synchronized(chessPeerHash) { chessPeerHash.put(serverName,selfName); } publicTalk(getUserList()); chessPeerTalk(selfName,("/peer "+"[inchess]"+serverName)); chessPeerTalk(serverName,("/peer "+"[inchess]"+selfName)); } else { chessPeerTalk(selfName,"/reject"); try { clientClose(); } catch(Exception ez) { } } } else if(message.startsWith("/[inchess]")) { int firstLocation=0,lastLocation; lastLocation=message.indexOf(" ",0); peerName=message.substring((firstLocation+1),lastLocation); message=message.substring((lastLocation+1)); if(chessPeerTalk(peerName,message)) { Feedback("/error"); } } else if(message.startsWith("/giveup ")) { String chessClientName=message.substring(8); if(chessPeerHash.containsKey(chessClientName) && !((String)chessPeerHash.get(chessClientName)).equals("wait")) { chessPeerTalk((String)chessPeerHash.get(chessClientName),"/youwin");
|