示例#1
0
        private void OnSessionRequest(P2PSessionRequest_t request)
        {
            CSteamID clientId = request.m_steamIDRemote;

            if (steamIdToConnection.ContainsKey(clientId))
            {
                SteamNetworking.AcceptP2PSessionWithUser(clientId);
            }
            else
            {
                if (steamIdToConnection.Count < maxConnections - 1)
                {
                    if (ShouldAcceptSteamId(clientId))
                    {
                        if (SteamNetworking.AcceptP2PSessionWithUser(clientId))
                        {
                            if (SteamNetworking.SendP2PPacket(clientId, null, 0, EP2PSend.k_EP2PSendReliable))
                            {
                                var conn = new SteamNetConnection(clientId);
                                ForceInitConnection(conn);

                                steamIdToConnection.Add(clientId, conn);

                                NetworkServer.AddExternalConnection(conn);
                            }
                        }
                    }
                    else
                    {
                        Debug.Log("Steam session request ignored");
                    }
                }
            }
        }
示例#2
0
    public void CreateP2PConnectionWithPeer(CSteamID peer)
    {
        Debug.Log("Sending P2P acceptance message and creating remote client reference for UNET server");
        SteamNetworking.SendP2PPacket(peer, null, 0, EP2PSend.k_EP2PSendReliable);

        // create new connnection for this client and connect them to server
        var newConn = new SteamNetworkConnection(peer);

        newConn.ForceInitialize();

        NetworkServer.AddExternalConnection(newConn);
        AddConnection(newConn);
    }
示例#3
0
    public override void OnConnected(NetworkConnection conn)
    {
        base.OnConnected(conn);

        NetworkServer.AddExternalConnection(conn);
    }
示例#4
0
 /// <summary>
 /// Handler for the Connect message of WebGL clients.
 /// </summary>
 /// <param name="netMsg">The network message that was received.</param>
 protected virtual void OnWebGLConnected(NetworkMessage netMsg)
 {
     NetworkServer.AddExternalConnection(netMsg.conn);
 }
示例#5
0
 void OnWebGLConnected(NetworkMessage netMsg)
 {
     Debug.Log("Connected");
     NetworkServer.AddExternalConnection(netMsg.conn);
 }