Skip to content

WatsonTcpServer.ListClients() is empty if called "too early" #223

Open
@Laiteux

Description

@Laiteux

Hey!

server.Start();
client.Connect();

Console.WriteLine(server.ListClients().Count());
await Task.Delay(1); // Thread.Sleep(1) also works
Console.WriteLine(server.ListClients().Count());

This will output:

0
1

This is very problematic as one might not expect server.ListClients() to return an empty enumerable, especially if they're not aware of this issue.

I'm not sure why a 1ms delay seems to fix it. Are some async events (registering the client on server side) not awaited/fired on time or something?

Why does this happen and could it be fixed?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions