This is really 2 different commits. Sorry about that. I can attempt to split them up another day but I didn't have the time and energy right now.
Also the state handling is not extremely pretty.. maybe can be written better but I wanted to commit something now so I can proceed to the next thing. You take it if you want it otherwise I'm happy to discuss how it could be written better.
Two changes:
The WebSocket session expires after 24h, when this happens Avanza
will send out a /meta/disconnect after which a new handshake must
be performed before any new operation can take place on the socket.
This code will initiate a new handshake upon reception of
/meta/disconnect or advice.reconnect='handshake'. Note that after
session expiry all subscriptions are lost.
In the event the TCP socket drops the 'ws' library will send
an 'close' event after which a new object must be instantiated
to create a new TCP connection. Once this connection is up a
/meta/connect will be sent out and subscriptions will continue
to function.
This is really 2 different commits. Sorry about that. I can attempt to split them up another day but I didn't have the time and energy right now.
Also the state handling is not extremely pretty.. maybe can be written better but I wanted to commit something now so I can proceed to the next thing. You take it if you want it otherwise I'm happy to discuss how it could be written better.
Two changes:
The WebSocket session expires after 24h, when this happens Avanza will send out a /meta/disconnect after which a new handshake must be performed before any new operation can take place on the socket. This code will initiate a new handshake upon reception of /meta/disconnect or advice.reconnect='handshake'. Note that after session expiry all subscriptions are lost.
In the event the TCP socket drops the 'ws' library will send an 'close' event after which a new object must be instantiated to create a new TCP connection. Once this connection is up a /meta/connect will be sent out and subscriptions will continue to function.