itisnajim / SocketIOUnity

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

Issue in unity #42

Open rihno123 opened 1 year ago

rihno123 commented 1 year ago

Hi, I have this issue. Capture 1

itisnajim commented 1 year ago

https://github.com/itisnajim/SocketIOUnity#receiving

rihno123 commented 1 year ago

https://github.com/itisnajim/SocketIOUnity#receiving

Can you be more detailed? I don't get it.

itisnajim commented 1 year ago

@rihno123, to retrieve your object, it is recommended to use the GetValue method. For example, to get an object of type 'SomeClass':

var obj = response.GetValue<SomeClass>();

If the object is a string, you can use:

string text = response.GetValue<string>();

Alternatively, if you wish to view the object as a stringified JSON, you can use:

string jsonStr = response.GetValue(0).GetRawText();
rihno123 commented 1 year ago

@rihno123, to retrieve your object, it is recommended to use the GetValue method. For example, to get an object of type 'SomeClass':

var obj = response.GetValue<SomeClass>();

If the object is a string, you can use:

string text = response.GetValue<string>();

Alternatively, if you wish to view the object as a stringified JSON, you can use:

string jsonStr = response.GetValue(0).GetRawText();

Ok, but when I use that line I get this error. Capture

SatoshiDark commented 1 year ago

Hi, I have the same issue as the first screenshot, I'm at Unity version 2021.3.17f1. I imported the package without issues, but when I copied the sample folder then the unity console log shows that error. As I'm just testing this package for the GGJ, I replaced the error line response.GetValue().GetRawText() with response.ToString() and seems to work, but I'll really appreciated if you can update the sample directory please.
Thanks!