Exemple #1
0
 public void MsgtoCli_RoomInGenral(Msg_RoomInGeneral sermsg)
 {
     if (sermsg.comcode == ComCode.CreateRoom)
     {
         GameMan._ins.SetupRoom_Cli(sermsg.roomids, true);
     }
 }
Exemple #2
0
 public void MsgtoSer_RoomInGeneral(NetworkConnection cliconn, Msg_RoomInGeneral inmsg)
 {
     if (inmsg.comcode == ComCode.CreateRoom)
     {
         //H.klog2($"Client - {cliconn} send me room req, what hsould id o", this.name);
         string id = H.GenIds();
         // set up room list on server, assign this cliconn as leader
         GameMan._ins.SetupRoom_Ser(id, cliconn, inmsg.urname);
         // assign the connection id with room id
         GameMan._ins.playerTab_ser.Add(cliconn.connectionId, id);
         // sending created room id to client
         Msg_RoomInGeneral sendtocli = new Msg_RoomInGeneral()
         {
             roomids = id, comcode = ComCode.CreateRoom
         };
         cliconn.Send(sendtocli);
         cliconn.Send(new Msg_Lobby {
             comcode = ComCode.SetLeader, ureleader = true
         });
     }
     else if (inmsg.comcode == ComCode.LeaveRoom)
     {
         Msg_Lobby resmsg = new Msg_Lobby {
             comcode = ComCode.LeaveRoom, playerconnid = cliconn.connectionId
         };
         // send message to all member to remove the one that leave
         //cli who sends this still connect to server
         if (GameMan._ins.roomTab_ser.ContainsKey(inmsg.roomids))
         {
             LeaveAndPromote(inmsg.roomids, cliconn, resmsg);
         }
         // remove player from player table
         H.klog($"remove LEAVING {cliconn.connectionId} from Game Manager");
         if (GameMan._ins.playerTab_ser.ContainsKey(cliconn.connectionId))
         {
             GameMan._ins.playerTab_ser.Remove(cliconn.connectionId);
         }
     }
 }