//send message to peers public void OnChat(NetPacket packet) { //display chat Chat.ChatProto proto = packet.ReadObject <Chat.ChatProto>(); if (proto != null) { Console.WriteLine(proto.userName + ": " + proto.chatMsg); } packet.BeginWrite("chat"); packet.WriteObject <Chat.ChatProto>(proto); packet.EncodeHeader(); foreach (Socket sk in peerList) { server.Send(sk, packet); } }
public void OnChat(NetPacket packet) { // 在服务器上显示聊天内容 Chat.ChatProto proto = packet.ReadObject <Chat.ChatProto>(); if (proto != null) { Debug.Log(proto.userName + ":" + proto.chatMsg); if (proto.chatMsg == "成功") { //生成二维码 上传GUID facade.SendMessageCommand(MessageDef.GameResult, "成功"); } else if (proto.chatMsg == "失败") { //生成二维码 facade.SendMessageCommand(MessageDef.GameResult, "失败"); } } }