Lidgren.Network.NetConnection.Approve C# (CSharp) Method

Approve() public method

Approves this connection; sending a connection response to the remote host
public Approve ( ) : void
return void
        public void Approve()
        {
            if (m_status != NetConnectionStatus.RespondedAwaitingApproval)
            {
                m_peer.LogWarning("Approve() called in wrong status; expected RespondedAwaitingApproval; got " + m_status);
                return;
            }

            m_localHailMessage = null;
            m_handshakeAttempts = 0;
            SendConnectResponse((float)NetTime.Now, false);
        }

Same methods

NetConnection::Approve ( NetOutgoingMessage localHail ) : void

Usage Example

Beispiel #1
0
        public void AddPlayer(NetConnection connection, PlayerInformation playerInfo)
        {
            String denyReason;
            Byte slot = AllocateSlot(playerInfo, out denyReason);

            // could not allocate the player if AllocateSlot returns DummySlot
            if (slot == ProtocolInformation.DummySlot)
            {
                Log.InfoFormat("Player \"{0}\" from {1} tried to join, but was rejected ({2}).",
                               playerInfo.Callsign, connection, denyReason);
                connection.Deny(denyReason);
                return;
            }

            // we can now approve the player if we get here
            connection.Approve();

            // add player to our list
            players[slot] = new Player(this, slot, connection, playerInfo);

            // and tell everyone else about this awesome new player
            Log.DebugFormat("Sending MsgAddPlayer to everyone else about player #{0}", slot);

            NetOutgoingMessage packet = Server.CreateMessage();

            MsgAddPlayerPacket message = new MsgAddPlayerPacket(players[slot].PlayerInfo, false);

            packet.Write((Byte)message.MsgType);
            message.Write(packet);

            Log.DebugFormat("MsgAddPlayer Compiled ({0} bytes) and being sent to {1} recipients",
                            packet.LengthBytes, players.Count - 1);

            // send to everyone except our new player, we let Player itself decide when to send the state to the new guy
            Server.SendToAll(packet, connection, NetDeliveryMethod.ReliableOrdered, 0);
        }
All Usage Examples Of Lidgren.Network.NetConnection::Approve