-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any way to subscript broken connection event? #160
Comments
Hi! Can you describe how the WebSocket server is bootstrapped? Do you use an intermediate HTTP server and upgrade the connection or you use the WebSocket server directly? Based on that I can help you better. Right now the |
Hi Józef,
Yes, I use an intermediate HTTP server and upgrade the connection or the
WebSocket server directly.
…On Wed, 14 Aug 2019 at 9:05 AM, Józef Flakus ***@***.***> wrote:
Hi!
Can you describe how the WebSocket server is bootstrapped? Do you use an
intermediate HTTP server and upgrade the connection or the WebSocket server
directly? Based on that I can help you better.
Right now the @marblejs/websockets module doesn't have "cool" direct
access to connected client events, but it will change in the next major
release. Right now I can propose you a temporary way of solving this
problem :)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#160?email_source=notifications&email_token=AABYSBKK7YYS3BZKW4T4ONDQEOVD3A5CNFSM4ILMOVRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4H4RFA#issuecomment-521128084>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABYSBPKBDTYFVCPDRCUJFTQEOVD3ANCNFSM4ILMOVRA>
.
|
Ok, so the temporary solution consists of reacting to const handleWsServerConnectionEvents = (wsServer: MarbleWebSocketServer) => {
wsServer.on('connection', conn => {
// do whatever you want... eg:
conn.send('hello!');
});
};
const listening$: HttpServerEffect = (event$, _, { ask }) =>
event$.pipe(
matchEvent(ServerEvent.listening),
map(event => event.payload),
tap(({ port, host }) => {
ask(WsServerToken)
.map(handleWsServerConnectionEvents)
.getOrElseL(() => { throw new Error('WsServerToken not bound to context'); });
console.log(`Server running @ http://${host}:${port}/ 🚀`);
}),
); |
Version 3.1 released. |
Hi there,
Is there any way to known when a websocket client's connection is broken so that I can do a follow-up action, e.g. update the database about the client's status.
The text was updated successfully, but these errors were encountered: