コード例 #1
0
        public async Task RelayEndtoEndFakeIP()
        {
            SteamNetworkingUtils.InitRelayNetworkAccess();
            SteamNetworkingUtils.DebugLevel     = NetDebugOutput.Warning;
            SteamNetworkingUtils.OnDebugOutput += DebugOutput;

            // For some reason giving steam a couple of seconds here
            // seems to prevent it returning null connections from ConnectNormal
            await Task.Delay(2000);

            Console.WriteLine($"----- Creating Socket Relay Socket..");
            var socket = SteamNetworkingSockets.CreateRelaySocketFakeIP <TestSocketInterface>();
            var server = socket.RunAsync();

            await Task.Delay(1000);

            Console.WriteLine($"----- Retrieving Fake IP..");
            SteamNetworkingSockets.GetFakeIP(0, out NetAddress address);

            Console.WriteLine($"----- Connecting To Socket via Fake IP ({address})");
            var connection = SteamNetworkingSockets.ConnectNormal <TestConnectionInterface>(address);
            var client     = connection.RunAsync();

            await Task.WhenAll(server, client);
        }
コード例 #2
0
        public async Task NormalEndtoEnd()
        {
            SteamNetworkingUtils.DebugLevel     = NetDebugOutput.Everything;
            SteamNetworkingUtils.OnDebugOutput += DebugOutput;

            // For some reason giving steam a couple of seconds here
            // seems to prevent it returning null connections from ConnectNormal
            await Task.Delay(2000);

            //
            // Start the server
            //
            Console.WriteLine("CreateNormalSocket");
            var socket = SteamNetworkingSockets.CreateNormalSocket <TestSocketInterface>(NetAddress.AnyIp(12445));
            var server = socket.RunAsync();

            //
            // Start the client
            //
            Console.WriteLine("ConnectNormal");
            var connection = SteamNetworkingSockets.ConnectNormal <TestConnectionInterface>(NetAddress.From("127.0.0.1", 12445));
            var client     = connection.RunAsync();

            await Task.WhenAll(server, client);
        }
コード例 #3
0
        public async Task NormalEndtoEnd()
        {
            var socket = SteamNetworkingSockets.CreateNormalSocket <TestSocketInterface>(NetAddress.AnyIp(12445));
            var server = socket.RunAsync();

            await Task.Delay(1000);

            var connection = SteamNetworkingSockets.ConnectNormal <TestConnectionInterface>(NetAddress.From(System.Net.IPAddress.Parse("127.0.0.1"), 12445));
            var client     = connection.RunAsync();

            await Task.WhenAll(server, client);
        }