itisnajim / SocketIOUnity

A Wrapper for socket.io-client-csharp to work with Unity.
MIT License
393 stars 67 forks source link

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

Closed DaveKap closed 2 years ago

DaveKap commented 2 years ago

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: https://github.com/doghappy/socket.io-client-csharp/issues/266

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

itisnajim commented 2 years ago

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

DaveKap commented 2 years ago

Thank you! Looking forward to it!

itisnajim commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

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 commented 2 years ago

@jingfu-wei please check now, i updated this: https://github.com/itisnajim/SocketIOUnity/blob/520ea721ce25d2a193ee4c3b50299f617c6d529e/Runtime/SocketIOUnity.cs#L85-L98

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

DaveKap commented 2 years ago

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.