public override IEnumerator OnReceive(Session session, Gamnet.Packet packet) { Packet.MsgCliSvr_Join_Req req = packet.Deserialize <Packet.MsgCliSvr_Join_Req>(); Packet.MsgSvrCli_Join_Ans ans = new Packet.MsgSvrCli_Join_Ans(); ans.errorCode = Packet.ErrorCode.Success; Room room = Main.Room.Find(req.roomId); room.AddUser(session); session.Send(ans); int needPlayerCount = 2; if (false == GameManager.Instance.multiPlay) { needPlayerCount = 1; } if (needPlayerCount == room.sessions.Count) { Main.Room.Remove(room.Id); room.Ready(); } yield break; }
public void OnConnect() { Packet.MsgCliSvr_Join_Req req = new Packet.MsgCliSvr_Join_Req(); Text roomId = ui.roomId.transform.Find("Text").GetComponent <Text>(); if ("" == roomId.text) { roomId = ui.roomId.transform.Find("Placeholder").GetComponent <Text>(); } req.roomId = UInt32.Parse(roomId.text); Network.Send(req); }
public override IEnumerator OnReceive(Session session, Gamnet.Packet packet) { Packet.MsgCliSvr_Join_Req req = packet.Deserialize <Packet.MsgCliSvr_Join_Req>(); Packet.MsgSvrCli_Join_Ans ans = new Packet.MsgSvrCli_Join_Ans(); ans.errorCode = Packet.ErrorCode.Success; Room room = Main.Room.Find(req.roomId); room.AddUser(session); session.Send(ans); if (1 == room.sessions.Count) { Main.Room.Remove(room.Id); room.Ready(); } yield break; }