Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EmitAsync doesn't work #134

Closed
KaizoKev opened this issue Apr 15, 2021 · 11 comments
Closed

EmitAsync doesn't work #134

KaizoKev opened this issue Apr 15, 2021 · 11 comments

Comments

@KaizoKev
Copy link

KaizoKev commented Apr 15, 2021

Hello,

When I do an EmitAsync of an event to receive it in my nodeJS server I get nothing no events go off, I have tried all of them, do you have a solution to make this work?

C# :

client.OnConnected += async (a, b) => {
    await client.EmitAsync("hi", "Je suis connecté");
};
await client.ConnectAsync();

NodeJS :

socket.on("hi", name => {
    console.log("hello");
});
@doghappy
Copy link
Owner

Make sure that the OnConnected event is triggered.

client.OnConnected += async (a, b) => {
    Console.WriteLine("OnConnected");
    await client.EmitAsync("hi", "Je suis connecté");
};
await client.ConnectAsync();

You can add a log or detect whether an event is triggered by a breakpoint.

@KaizoKev
Copy link
Author

Yes is triggered but not the emit ;(

The problem does not come from the fact that it is asynchronous ?

@doghappy
Copy link
Owner

Can you provide a reproducible github repo, including socket.io server and client?

@KaizoKev
Copy link
Author

Yes no worries, just before I will try to deploy it on my server and do some test, then I will put it on a github repo.

@whoishina
Copy link

+1 Problem

@doghappy
Copy link
Owner

Please provide more information

@whoishina
Copy link

I've check back my server config and this problem was resolved.

@KaizoKev
Copy link
Author

I still have the same problem, the emitasync is not working, is it because I am local? I add you one to a github repo doghappy.

@doghappy
Copy link
Owner

doghappy commented Jul 30, 2021

@KevinCeyland I pushed 2 commits to your repo. It seems that you are using socket.io server incorrectly.

Send cmd broadcast from index.html, the client can also receive it.

image

Sorry, I deleted a lot of code, I assume it is all sample code. After solving the problem, you can reset/revert from git.

@KaizoKev
Copy link
Author

Thanks !! it works, on the other hand I cannot do an emitAsync outside :

client.OnConnected += async(a,b) => {

}
How can I send data like the IP back to my web interface ?

@doghappy
Copy link
Owner

doghappy commented Aug 2, 2021

I pushed a commit. When the client connects/disconnects, the ip list of the html interface will be updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants