Git Product home page Git Product logo

Comments (6)

Henry00IS avatar Henry00IS commented on July 29, 2024 2

I have fixed the OnDisconnected event. It will always fire now, immediately.

from websocket-manager.

llamas77 avatar llamas77 commented on July 29, 2024 2

Thanks @Henry00IS . Its working!

from websocket-manager.

jcyuan avatar jcyuan commented on July 29, 2024

I have the same question. how to do heartbeat?

from websocket-manager.

jcyuan avatar jcyuan commented on July 29, 2024

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.

awosztyl avatar awosztyl commented on July 29, 2024

from websocket-manager.

jcyuan avatar jcyuan commented on July 29, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.