mirror of
https://github.com/fosrl/olm.git
synced 2026-02-08 05:56:41 +00:00
Reorder websocket disconnect message
This commit is contained in:
14
olm/olm.go
14
olm/olm.go
@@ -480,7 +480,12 @@ func (o *Olm) StartTunnel(config TunnelConfig) {
|
|||||||
|
|
||||||
func (o *Olm) Close() {
|
func (o *Olm) Close() {
|
||||||
// send a disconnect message to the cloud to show disconnected
|
// send a disconnect message to the cloud to show disconnected
|
||||||
o.websocket.SendMessage("olm/disconnecting", map[string]any{})
|
if o.websocket != nil {
|
||||||
|
o.websocket.SendMessage("olm/disconnecting", map[string]any{})
|
||||||
|
// Close the websocket connection after sending disconnect
|
||||||
|
_ = o.websocket.Close()
|
||||||
|
o.websocket = nil
|
||||||
|
}
|
||||||
|
|
||||||
// Restore original DNS configuration
|
// Restore original DNS configuration
|
||||||
// we do this first to avoid any DNS issues if something else gets stuck
|
// we do this first to avoid any DNS issues if something else gets stuck
|
||||||
@@ -567,12 +572,7 @@ func (o *Olm) StopTunnel() error {
|
|||||||
time.Sleep(200 * time.Millisecond)
|
time.Sleep(200 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the websocket connection
|
// Close() will handle sending disconnect message and closing websocket
|
||||||
if o.websocket != nil {
|
|
||||||
_ = o.websocket.Close()
|
|
||||||
o.websocket = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
o.Close()
|
o.Close()
|
||||||
|
|
||||||
// Reset the connected state
|
// Reset the connected state
|
||||||
|
|||||||
Reference in New Issue
Block a user