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

Can we get support for socket.io-client-csharp 3.0.6? #13

Closed
DaveKap opened this issue May 23, 2022 · 8 comments
Closed

Can we get support for socket.io-client-csharp 3.0.6? #13

DaveKap opened this issue May 23, 2022 · 8 comments

Comments

@DaveKap
Copy link

DaveKap commented May 23, 2022

After getting help from a friend, I discovered that the reason I was having such issues using this plugin's auth methodology was because it's using an older version of socket.io-client-csharp. The newer version, updated in March, allows for authentication middleware support, which I need!
See the fix here:
doghappy/socket.io-client-csharp#266

Would it be possible to update SocketIOUnity to support socket.io-client-csharp 3.0.6?

@itisnajim
Copy link
Owner

i'll do an update tomorrow, and to support more Unity versions too

@DaveKap
Copy link
Author

DaveKap commented May 24, 2022

Thank you! Looking forward to it!

@itisnajim
Copy link
Owner

itisnajim commented May 26, 2022

you are welcome,
try now https://github.com/itisnajim/SocketIOUnity/releases/tag/v1.1.1

add package from git URL the url https://github.com/itisnajim/SocketIOUnity.git
or specify the version like this: https://github.com/itisnajim/SocketIOUnity.git#v1.1.1

@DaveKap
Copy link
Author

DaveKap commented May 26, 2022

Thanks! Unfortunately, I got a few warnings and an error upon updating. I tried reinstalling fresh and still got the same errors:
https://i.imgur.com/bOxWcHY.png

Looking into it, deleting the meta file in the warnings makes those go away but the Router error is still a problem.

Edit: On the bright side, commenting out that error line (which I know cripples the functionality of the plugin in some way that will probably bite me down the line) got me running code which I then tested to auth against the server I've been trying to connect to this whole time and... it was successful! So at least I can proceed a bit with my work but, obviously, whatever that error was should get fixed for anyone else and likely whatever issues that would cause down the line. Thanks again for checking this out!

@jingfu-wei
Copy link

Thanks for the amazing update. I also encountered the problem with

error CS0103: The name 'Router' does not exist in the current context

After comparing with version 1.1.0, I found that the folder Routers was removed from Runtime\SocketIOClient. Was this intentional?

@jingfu-wei
Copy link

After checking socket.io-client-csharp, I have managed to resolve this issue:

  • replace Router with _transport at line 97 in Runtime\SocketIOUnity.cs
  • _transport was set as private in SocketIO which was defined in Runtime\SocketIOClient\SocketIO.cs, so you need to set _transport either public or protected

This should work. However, I noticed the delay in responsding events sent from the server for some reason. V1.1.0 does not have this problem.

@itisnajim
Copy link
Owner

@jingfu-wei
please check now,
i updated this:

public async Task EmitStringAsJSONAsync(string eventName, string json)
{
var msg = new EventMessage
{
Namespace = Namespace,
Event = eventName,
};
if (!string.IsNullOrEmpty(json))
{
msg.Json = "["+json+"]";
}
await _transport.SendAsync(msg, cancellationToken).ConfigureAwait(false);
}

i have no way to test it right now, so tell me if i need to modify something ..

@DaveKap
Copy link
Author

DaveKap commented May 27, 2022

As far as I could tell, implementing the changes jingfu-wei mentioned got things working just as well as they did with commenting out the line altogether. I didn't notice lag in the communications, either.

However, making the change you've shown above causes a new error because cancellationToken is unknown name. Tacking ConfigureAwait(false) onto the end of the unchanged line, however, works fine.

So the only change ends up being line 97 looking like this:
await _transport.SendAsync(msg, CancellationToken.None).ConfigureAwait(false);

Considering it seems like you may have pulled this line from SocketIO.cs, where CancellationToken.None is the default value being thrown into functions where cancellationToken exists, I'm not sure this affects anything.

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