Comments (5)
If the connection is disconnected by the server, the OnClosed
event will be called and the parameter value is ClosedByServer. If the server process exits, the OnClosed
event will be called too and the parameter value is Aborted.
According to your description, I can't reproduce it. I would be very grateful if you can help me with it.
I used the code to test it and the test results were successful.
server
io.on('connection', client => {
client.on('close', data => {
if (data === "close") {
client.disconnect();
}
});
client.on('disconnect', () => {
console.log(`disconnect: ${client.id}`);
});
});
console.log('Socket IO server started');
client
static async Task Main(string[] args)
{
var client = new SocketIO("http://localhost:3000");
client.OnClosed += reason => Console.WriteLine(reason);
client.OnConnected += () =>
{
Console.WriteLine("Connected");
};
await client.ConnectAsync();
await Task.Delay(1000);
await client.EmitAsync("close", "close");
Console.ReadLine();
}
result
from socket.io-client-csharp.
Yes, I test your code and it's work. but what if my server gets down? how your implementation can handle it and client understand the connection is lost and the server is not available after connection?
from socket.io-client-csharp.
In general, if the connection is closed by server, the server will return a specific code number(reason = ClosedByServer). But there is still a thread that polls for server status(reason = Aborted)
from socket.io-client-csharp.
Right, I tested in a console application and it's work. I think it has a problem when running in unity. in unity, can't get the "Aborted" message
from socket.io-client-csharp.
@farzadi Can you share your sample code for connecting to unity? We are having a difficult time setting that up.
from socket.io-client-csharp.
Related Issues (20)
- 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
- MessagePack deserialization ignores key attributes HOT 2
- How to use this library in a C# .NET project HOT 2
- .net 6.0 System.Text.Json conflict
- Extra Headers are not taking JSON payloads HOT 1
- When use unity not working HOT 2
- The server returned status code '400' when status code '101' was expected. HOT 1
- How can I find out if the verification failed? HOT 1
- EmitAsync doesn't seem to work with data parameters HOT 1
- Updating to version 3.1.1 leads to error CS0118 HOT 2
- Help using nuget HOT 2
- Connection hanging, not connecting HOT 1
- about EmitAsync HOT 1
- about DisconnectAsync HOT 1
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.