Exemplo n.º 1
0
        public async Task RoomsTest()
        {
            using var tokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10));
            var cancellationToken = tokenSource.Token;

            await BaseTests.BaseTestAsync(
                async client =>
            {
                await client.ConnectAsync(new Uri(LocalCharServerUrl), cancellationToken);
                await client.Emit("message", cancellationToken: cancellationToken);

                await Task.Delay(TimeSpan.FromSeconds(2), cancellationToken);

                await client.DisconnectAsync(cancellationToken);
            },
                cancellationToken,
                nameof(SocketIoClient.EventReceived),
                nameof(SocketIoClient.UnhandledEventReceived));
        }
Exemplo n.º 2
0
        public async Task ConnectToLocalChatServerNamespaceTest2()
        {
            using var tokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10));
            var cancellationToken = tokenSource.Token;

            await BaseTests.BaseTestAsync(
                async client =>
            {
                BaseTests.EnableDebug(client);

                await client.ConnectAsync(new Uri(LocalCharServerUrl), cancellationToken, "my");

                await Task.Delay(TimeSpan.FromMilliseconds(200), cancellationToken);
                await client.Emit("message", "hello", "my", cancellationToken);
                await Task.Delay(TimeSpan.FromSeconds(2), cancellationToken);

                await client.DisconnectAsync(cancellationToken);
            },
                cancellationToken,
                nameof(SocketIoClient.EventReceived),
                nameof(SocketIoClient.UnhandledEventReceived));
        }