O'Reilly logo

Isomorphic Go by Kamesh Balasubramanian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling a disconnection event

This leads us to the last function, HandleDisconnection, which is called either on an abnormal WebSocket connection close event or when the internet connection has been disconnected, that is, when the wenv.Window object fires an offline event:

func HandleDisconnection(env *common.Env) {  chatContainer := env.Document.GetElementByID("chatboxContainer").(*dom.HTMLDivElement)  chatContainer.SetClass("")  chatboxHeaderBar := env.Document.GetElementByID("chatboxHeaderBar").(*dom.HTMLDivElement)  chatboxHeaderBar.SetClass("chatboxHeader disconnected")  chatboxTitleDiv := env.Document.GetElementByID("chatboxTitle").(*dom.HTMLDivElement)  if chatboxTitleDiv != nil { titleSpan := chatboxTitleDiv.ChildNodes()[0].(*dom.HTMLSpanElement) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required