示例#1
0
        void SendFailedConnection(CSteamID recip, EGSConnectionError connectionError, string reason = "")
        {
            Packet packet = new Packet(this, true, Packet.PACKET_AUTHFAILED);

            packet.Write((int)connectionError);
            if(reason != string.Empty)
            {
                packet.Write(reason);
            }

            packet.Send(EP2PSend.k_EP2PSendReliable, 0, recip);
        }
示例#2
0
        void OnClientWantsAuth(CSteamID steamIDRemote, byte[] authPub, int authCub)
        {
            if(_Players.ContainsKey(steamIDRemote)){
                // This got called again, why did it?
                return;
            }

            if(_Players.Count >= MaxPlayers){
                SendFailedConnection(steamIDRemote, EGSConnectionError.ServerFull);
            }

            if (SteamGameServer.BeginAuthSession(authPub, authCub, steamIDRemote) != EBeginAuthSessionResult.k_EBeginAuthSessionResultOK){
                SendFailedConnection(steamIDRemote, EGSConnectionError.AuthenticationError);
            }

            _Players.Add(steamIDRemote, EPlayerStatus.Pending);

            if(PlayerAuthenticated != null)
                PlayerAuthenticated(steamIDRemote);

            Packet msg = new Packet(this, true, Packet.PACKET_AUTHSUCCESS);
            msg.Send(EP2PSend.k_EP2PSendReliable, 0, steamIDRemote);
        }