/// <summary> /// use different logic to deal with different message /// </summary> /// <param name="type">message type</param> private static void ProcessMessage(Message msg, IPEndPoint remoteEndPoint) { ProcessMessage processMessage = new ProcessMessage(msg, udpClient); switch (msg.Type) { case MessageEnum.SIGN_IN: processMessage.SignIn_Server(remoteEndPoint); break; case MessageEnum.SIGN_OUT: processMessage.SignOut_Server(remoteEndPoint); break; case MessageEnum.CHAT: //processMessage.Chat(); break; default: Log.Write(String.Format("MessageEnum doesn't have {0}", msg.Type)); break; } }
/// <summary> /// use different logic to deal with different message /// </summary> /// <param name="type">message type</param> private static async Task ProcessMessage(Message msg, IPEndPoint remote) { ProcessMessage processMessage = new ProcessMessage(msg, udpClient); switch (msg.Type) { case MessageEnum.SIGN_IN: if (SignInNotify != null) { SignInNotify(msg); } break; case MessageEnum.SIGN_OUT: if (SignOutNotify != null) { SignOutNotify(msg); } break; case MessageEnum.CHAT: if (ReceiveMessageNotify != null) { ReceiveMessageNotify(msg); // 通知客户端收到聊天信息 } break; case MessageEnum.FILE: await ReceiveClientFile(msg, remote); break; default: Log.Write(String.Format("MessageEnum doesn't have {0}", msg.Type)); break; } }