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

Creating the live chat client

We will use the gopherjs/websocket/websocketjs package to create a WebSocket connection that will be used to connect to the web server instance.

You can install this package using the following go get command:

$ go get -u github.com/gopherjs/websocket

The client-side implementation of the live chat feature can be found in the client/chat/chat.go source file. We define the ws variable of the type websocketjs.WebSocket and the agentInfo variable of type map[string]string:

var ws *websocketjs.WebSocketvar agentInfo map[string]string

We also declare a constant that represents the key code for the Enter key:

const ENTERKEY int = 13

The GetAgentInfoRequest function is used to obtain the agent information from the ...

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