示例#1
0
 private void OnConnectionFailed(Steamworks.SteamId steamId, Steamworks.P2PSessionError error)
 {
     if (!isActive) { return; }
     if (steamId != hostSteamId) { return; }
     Close($"SteamP2P connection failed: {error}");
     OnDisconnectMessageReceived?.Invoke($"SteamP2P connection failed: {error}");
 }
示例#2
0
 private void OnIncomingConnection(Steamworks.SteamId steamId)
 {
     if (!isActive)
     {
         return;
     }
     if (steamId == hostSteamId)
     {
         Steamworks.SteamNetworking.AcceptP2PSessionWithUser(steamId);
     }
 }
示例#3
0
        private void OnIncomingConnection(Steamworks.SteamId steamId)
        {
            if (!isActive)
            {
                return;
            }

            if (!remotePeers.Any(p => p.SteamID == steamId))
            {
                remotePeers.Add(new RemotePeer(steamId));
            }

            Steamworks.SteamNetworking.AcceptP2PSessionWithUser(steamId); //accept all connections, the server will figure things out later
        }
示例#4
0
 private void OnIncomingConnection(Steamworks.SteamId steamId)
 {
     if (!isActive) { return; }
     if (steamId == hostSteamId)
     {
         Steamworks.SteamNetworking.AcceptP2PSessionWithUser(steamId);
     }
     else if (initializationStep != ConnectionInitialization.Password &&
              initializationStep != ConnectionInitialization.Success)
     {
         DebugConsole.ThrowError($"Connection from incorrect SteamID was rejected: "+
             $"expected {SteamManager.SteamIDUInt64ToString(hostSteamId)}," +
             $"got {SteamManager.SteamIDUInt64ToString(steamId)}");
     }
 }
示例#5
0
        private void OnAuthChange(Steamworks.SteamId steamID, Steamworks.SteamId ownerID, Steamworks.AuthResponse status)
        {
            RemotePeer remotePeer = remotePeers.Find(p => p.SteamID == steamID);

            DebugConsole.Log(steamID + " validation: " + status + ", " + (remotePeer != null));

            if (remotePeer == null)
            {
                return;
            }

            if (remotePeer.Authenticated)
            {
                if (status != Steamworks.AuthResponse.OK)
                {
                    DisconnectPeer(remotePeer, DisconnectReason.SteamAuthenticationFailed.ToString() + "/ Steam authentication status changed: " + status.ToString());
                }
                return;
            }

            if (status == Steamworks.AuthResponse.OK)
            {
                remotePeer.OwnerSteamID   = ownerID;
                remotePeer.Authenticated  = true;
                remotePeer.Authenticating = false;
                foreach (var msg in remotePeer.UnauthedMessages)
                {
                    //rewrite the owner id before
                    //forwarding the messages to
                    //the server, since it's only
                    //known now
                    int prevBitPosition = msg.Message.BitPosition;
                    msg.Message.BitPosition = sizeof(ulong) * 8;
                    msg.Message.Write(ownerID);
                    msg.Message.BitPosition = prevBitPosition;
                    byte[] msgToSend = (byte[])msg.Message.Buffer.Clone();
                    Array.Resize(ref msgToSend, msg.Message.LengthBytes);
                    ChildServerRelay.Write(msgToSend);
                }
                remotePeer.UnauthedMessages.Clear();
            }
            else
            {
                DisconnectPeer(remotePeer, DisconnectReason.SteamAuthenticationFailed.ToString() + "/ Steam authentication failed: " + status.ToString());
                return;
            }
        }
示例#6
0
        private void OnAuthChange(Steamworks.SteamId steamID, Steamworks.SteamId ownerID, Steamworks.AuthResponse status)
        {
            if (netServer == null)
            {
                return;
            }

            PendingClient pendingClient = pendingClients.Find(c => c.SteamID == steamID);

            DebugConsole.Log(steamID + " validation: " + status + ", " + (pendingClient != null));

            if (pendingClient == null)
            {
                if (status != Steamworks.AuthResponse.OK)
                {
                    LidgrenConnection connection = connectedClients.Find(c => c.SteamID == steamID) as LidgrenConnection;
                    if (connection != null)
                    {
                        Disconnect(connection, DisconnectReason.SteamAuthenticationFailed.ToString() + "/ Steam authentication status changed: " + status.ToString());
                    }
                }
                return;
            }

            LidgrenConnection pendingConnection = pendingClient.Connection as LidgrenConnection;
            string            banReason;

            if (serverSettings.BanList.IsBanned(pendingConnection.NetConnection.RemoteEndPoint.Address, steamID, ownerID, out banReason))
            {
                RemovePendingClient(pendingClient, DisconnectReason.Banned, banReason);
                return;
            }

            if (status == Steamworks.AuthResponse.OK)
            {
                pendingClient.OwnerSteamID       = ownerID;
                pendingClient.InitializationStep = serverSettings.HasPassword ? ConnectionInitialization.Password : ConnectionInitialization.ContentPackageOrder;
                pendingClient.UpdateTime         = Timing.TotalTime;
            }
            else
            {
                RemovePendingClient(pendingClient, DisconnectReason.SteamAuthenticationFailed, "Steam authentication failed: " + status.ToString());
                return;
            }
        }
示例#7
0
        private void OnAuthChange(Steamworks.SteamId steamID, Steamworks.SteamId ownerID, Steamworks.AuthResponse status)
        {
            RemotePeer remotePeer = remotePeers.Find(p => p.SteamID == steamID);

            DebugConsole.Log(steamID + " validation: " + status + ", " + (remotePeer != null));

            if (remotePeer == null)
            {
                return;
            }

            if (remotePeer.Authenticated)
            {
                if (status != Steamworks.AuthResponse.OK)
                {
                    DisconnectPeer(remotePeer, DisconnectReason.SteamAuthenticationFailed.ToString() + "/ Steam authentication status changed: " + status.ToString());
                }
                return;
            }

            if (status == Steamworks.AuthResponse.OK)
            {
                remotePeer.Authenticated  = true;
                remotePeer.Authenticating = false;
                foreach (var msg in remotePeer.UnauthedMessages)
                {
                    byte[] msgToSend = (byte[])msg.Message.Buffer.Clone();
                    Array.Resize(ref msgToSend, msg.Message.LengthBytes);
                    ChildServerRelay.Write(msgToSend);
                }
                remotePeer.UnauthedMessages.Clear();
            }
            else
            {
                DisconnectPeer(remotePeer, DisconnectReason.SteamAuthenticationFailed.ToString() + "/ Steam authentication failed: " + status.ToString());
                return;
            }
        }
示例#8
0
 public void OnLobbyJoinRequested(Steamworks.Data.Lobby lobby, Steamworks.SteamId friendId)
 {
     SteamManager.JoinLobby(lobby.Id, true);
 }