Beispiel #1
0
        public void NewData(PlayerConnection pc, int dataLength, byte[] data)
        {
            var recipent = pc.NetConnection == playersConnections[0] ? playersConnections[1] : playersConnections[0];
            var msg      = Server.server.CreateMessage();

            msg.Write(dataLength);
            msg.Write(data);
            Server.server.SendMessage(msg, recipent, NetDeliveryMethod.UnreliableSequenced);
        }
Beispiel #2
0
        public void AddPlayerToMatchmaking(NetConnection netConnection)
        {
            if (waitingPlayerConnection == null)
            {
                waitingPlayerConnection = new PlayerConnection(netConnection);
                allPlayerConnections.Add(waitingPlayerConnection);
                return;
            }

            try {
                waitingPlayerConnection.Session = new Session(waitingPlayerConnection.NetConnection, netConnection);
            } catch (ArgumentNullException argE) {
                Console.WriteLine(argE.Message);
            }

            allSessions.Add(waitingPlayerConnection.Session);
            allPlayerConnections.Add(new PlayerConnection(netConnection, waitingPlayerConnection.Session));
            waitingPlayerConnection = null;
        }