void UpdateRoomInfo(MemoryStream ms) { MessageNotifyRoomInfo info = MessageNotifyRoomInfo.Parser.ParseFrom(ms); text_num.text = info.PlayerInfoArray.Count.ToString(); if (info.FightState == 1) { Singleton <GameModel> .GetInstance().UID = info.SelfUid; Singleton <GameModel> .GetInstance().roomInfoList.Clear(); Singleton <GameModel> .GetInstance().roomInfoList.AddRange(info.PlayerInfoArray); heartTimer.stop(); UnityEngine.SceneManagement.SceneManager.LoadScene("Play"); } }
static void NotifyRoomInfo() { if (StartFightFlag) { roomInfoTimer.stop(); } MessageNotifyRoomInfo msg = new MessageNotifyRoomInfo(); //0:等待 1:开战中 msg.FightState = StartFightFlag ? 1 : 0; msg.PlayerInfoArray.AddRange(roomInfoList); foreach (var client in clientConnectionItems) { msg.SelfUid = client.Key; MemoryStream memory = new MemoryStream(); Google.Protobuf.MessageExtensions.WriteTo(msg, memory); ByteBuffer buffer = createByteBuffer((ushort)MSG_CS.NotifyRoomInfo, memory); if (client.Value.Connected) { client.Value.BeginSend(buffer.ToBytes(), 0, buffer.ToBytes().Length, SocketFlags.None, null, null); } } }