Comments (2)
var obj = JObject.Parse(response.GetValue<string>());
I find method response.GetValue<string>())
get jsonstring. Sorry i'm newbie C#
from socket.io-client-csharp.
@mrx-bell
In the example you gave, what you send to the client is actually a string.
You can parse like this:
socket.On("TEST", response =>
{
string json = response.GetValue<string>();
// {"message": "Test", "status": 1}
var obj = JObject.Parse(json);
string message = obj.Value<string>("message");
int status = obj.Value<int>("status");
});
But I recommend this:
server
socket.emit("TEST", {message: 'Test', status: 1});
client
class TestResponse
{
[JsonProperty("message")]
public string Message { get; set; }
[JsonProperty("status")]
public int Status { get; set; }
}
socket.On("TEST", response =>
{
var testResponse = response.GetValue<TestResponse>();
Console.WriteLine(testResponse.Message);
Console.WriteLine(testResponse.Status);
});
from socket.io-client-csharp.
Related Issues (20)
- Is there any active socket.io server implementation? HOT 2
- ReconnectionDelay Bug HOT 3
- Nugget package(SocketIOClient.Windows7) version is low
- Socket.io client connects but doesn't emit in a Unity project HOT 2
- MsgPack encoding support instead of Json HOT 4
- Does the v4 version skip the first byte when receiving binarry data? HOT 6
- Import issues in Unity HOT 1
- In Web GL Build, socket connection is not established. HOT 2
- How can I assign json data to variables? HOT 2
- Problem with Connenct to flask_socketio HOT 1
- how to Connect soketIO 2.x HOT 2
- VSTHRD101 Avoid unsupported async delegates
- `System.ObjectDisposedException` while sending payload. HOT 1
- Can't connect socketIO HOT 7
- Nothing happens when trying to connect
- Responses not being caught??? HOT 1
- PlatformNotSupportedException HOT 2
- Pack dependencies resolving the wrong dll SocketIo.Core instead of SocketIO.Core HOT 3
- Support emit events concurrently HOT 1
- IOS Socet IO Xamarin.Forms Not connecting but Xamarin.Forms Android version working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from socket.io-client-csharp.