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 seem to work with data parameters #349

Closed
deleojur opened this issue Dec 28, 2023 · 1 comment
Closed

EmitAsync doesn't seem to work with data parameters #349

deleojur opened this issue Dec 28, 2023 · 1 comment

Comments

@deleojur
Copy link

I have a connection with a Node.JS server. Sending empty messages works fine. receiving messages from the server also works fine. However, when I try to send some additional data with the EmitAsync function, it does not register anything. There is no exception thrown or anything of this nature; the server just does not receive a message.

This is my code::

public void SendDataPacket(DataPacket dataPacket)
{
    //if the client is connected, send the dataPacket. If not, add it to the queue to be sent at a later time.
    if (client.Connected)
    {
        string data = dataPacket.ToJson();
        byte[] bytes = Encoding.ASCII.GetBytes(data);

        //None of these calls are registered on the server side.
        client.EmitAsync(dataPacket.EventName, bytes);
        client.EmitAsync(dataPacket.EventName, data);
        client.EmitAsync(dataPacket.EventName, dataPacket);

        //This works fine.
        client.EmitAsync(dataPacket.EventName);
    } else
    {
        dataPackets.Enqueue(dataPacket);
    }
}

I already checked that the object in question can be serialized. Sending an empty string also does not work.

On the back end side, this is my Javascript code

socket.on('request received', (request) => {
  console.log('some request received', request); 
});

Debugging either instance does not resolve in any meaningful errors or other casuses for this problem.
Any help is greatly appreciated.

@deleojur
Copy link
Author

deleojur commented Dec 29, 2023

Updating to version 3.1.1 seems to resolve this issue, but leads to issue #350.

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

1 participant