Comments (6)
I have fixed the OnDisconnected event. It will always fire now, immediately.
from websocket-manager.
Thanks @Henry00IS . Its working!
from websocket-manager.
I have the same question. how to do heartbeat?
from websocket-manager.
problem seems solved:
create your own Hub:
class myhub : WebSocketHandler { private List<User> _users {get;set;} }
then User class:
class User { timer.Elapsed += e => { if(elapsed > timeout) onTimeout.emit(); else if(elapsed % interval == 0) onHeartBeat.emit(); } }
and in myhub class override onConnected
method, you have to create an User and listen to both timeout/heartbeat events once new connection arrives.
and once you got timeout event emitted from User class, close the connection and do clear.
and do InvokeClientMethodAsync
to send heartbeat event for once you got heartbeat event from the user class.
the client should listen to "heartbeat" event and inovke back (send { methodName: "ReceiveHeartBeat" }) to server again, and in myhub class write "ReceiveHeartBeat" method, the WebSocketHnadler (the base class) will find the corresponding method and invoke it for you, in that method, reset user.elapsed = 0.
from websocket-manager.
from websocket-manager.
@awosztyl thank you, I have just read it.
but I wonder why only catch the exception for "All" method eg. sendmessagetoALLasync
this error will only occur when the server wants to deal with the client. so what if the server does not send any thing to the client for a long time?
by the way I have a question, what is the correct way to pass the current logged-in user to the WebSocketHandler?
from websocket-manager.
Related Issues (20)
- Unnecessary assignment (?) HOT 4
- Thread safety
- how to access HttpContext etc. in the sub class inherits from WebSocketHandler? HOT 3
- Unable to use send/receive complex types that are not part of the libarary HOT 4
- json format to sent message HOT 2
- dependency injection in the subclass inherits from WebsocketHandler HOT 3
- Inject dependency rather than using new
- json error in mvc sample HOT 1
- How to call server in c# client
- Cannot inject dependencies in the sockethandler or use servicelocator to do so HOT 1
- WebSocketHandler and WebSocketConnectionManager lifetime HOT 1
- The remote party closed the WebSocket connection without completing the close handshake. HOT 2
- Build string to send in socket to server
- NuGet package upgrade
- When hanlder ReceiveAsync method is doing something take a long time,the websocket cannot receive any message
- I fail to run WebTerm HOT 1
- NuGet update
- How to hosting Chat application in IIS HOT 2
- Suggestions: ControllerMethodInvocationStrategy with Async Tasks and ASP.NET Core 3.x Endpoints
- System.OutOfMemoryException
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 websocket-manager.