コード例 #1
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);
    }
コード例 #2
0
    void ConnectToUnetServerForSteam(CSteamID hostSteamId)
    {
        Debug.Log("Connecting to UNET server");

        // Create connection to host player's steam ID
        var conn          = new SteamNetworkConnection(hostSteamId);
        var mySteamClient = new SteamNetworkClient(conn);

        this.myClient = mySteamClient;

        // Setup and connect
        mySteamClient.RegisterHandler(MsgType.Connect, OnConnect);
        mySteamClient.SetNetworkConnectionClass <SteamNetworkConnection>();
        mySteamClient.Configure(SteamNetworkManager.hostTopology);
        mySteamClient.Connect();
    }