private bool IntenalReceive() { byte[] bufCmd = new byte[1]; try { serverSock.Receive(bufCmd); } catch { return(false); } PROTOCOL_CMD cmd = (PROTOCOL_CMD)bufCmd[0]; IProcessReceive processReceive = null; switch (cmd) { case PROTOCOL_CMD.LOGIN_RESULT: processReceive = new ProcessLoginResult(); break; case PROTOCOL_CMD.PROTOCAL_ILLEGAL: processReceive = new ProcessProtocolIllegal(); break; case PROTOCOL_CMD.TXTMSG: processReceive = new ProcessTxtMsg(); break; case PROTOCOL_CMD.FRIENDS_LIST: processReceive = new ProcessFriendList(); break; case PROTOCOL_CMD.REGIST_RESULT: processReceive = new ProcessRegistResult(); break; case PROTOCOL_CMD.NEW_USER_ONLINE: processReceive = new ProcessNewUserOnline(); break; case PROTOCOL_CMD.HEART_BEAT: processReceive = new ProcessHeartBeat(); break; case PROTOCOL_CMD.LOGOUT: processReceive = new ProcessLogout(); break; case PROTOCOL_CMD.FILEMSG: processReceive = new ProcessFileMsg(AppDomain.CurrentDomain.BaseDirectory + @"Faces"); break; } if (processReceive != null) { processReceive.Process(serverSock); } return(true); }
private bool InternalReceive(Socket workerSock, IPEndPoint remoteEnd) { byte[] bufCmd = new byte[1]; try { var c = workerSock.Receive(bufCmd); if (c == 0) { return(false); } } catch { return(false); } PROTOCOL_CMD cmd = (PROTOCOL_CMD)bufCmd[0]; IProcessReceive processReceive = null; switch (cmd) { case PROTOCOL_CMD.LOGIN: processReceive = new ProcessLogin(); break; case PROTOCOL_CMD.PROTOCAL_ILLEGAL: processReceive = new ProcessProtocolIllegal(); break; case PROTOCOL_CMD.TXTMSG: processReceive = new ProcessTxtMsg(); break; case PROTOCOL_CMD.FILEMSG: processReceive = new ProcessFileMsg(); break; case PROTOCOL_CMD.GET_FRIENDS: processReceive = new ProcessGetFriends(); break; case PROTOCOL_CMD.LOGOUT: processReceive = new ProcessLogout(); break; case PROTOCOL_CMD.REGIST: processReceive = new ProcessRegist(); break; case PROTOCOL_CMD.HEART_BEAT: processReceive = new ProcessHeartBeat(); break; case PROTOCOL_CMD.DOWNLOAD_FACES: processReceive = new ProcessDownloadFaces(); break; default: break; } if (processReceive != null) { processReceive.Process(workerSock); } return(true); }