Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Package websocket will provide GopherJS bindings for the WebSocket API.

Notifications You must be signed in to change notification settings

liamcurry/websocket

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

websocket

Package websocket will provide GopherJS bindings for the WebSocket API.

It is currently in development and should not be considered stable. The public API is unfinished and will change.

Example

package main

import (
	"github.com/gopherjs/gopherjs/js"
	"github.com/gopherjs/websocket"
	"honnef.co/go/js/console"
)

func main() {
	ws := websocket.New("http://localhost:9001/ws")
	//ws := websocket.NewWithGlobal("SockJS", "http://localhost:9001/ws")

	ws.OnOpen(func(obj js.Object) {
		console.Log("opened", obj)
	})

	ws.OnError(func(obj js.Object) {
		console.Log("error", obj)
	})

	ws.OnClose(func(obj js.Object) {
		console.Log("closed", obj)
	})

	ws.OnMessage(func(obj js.Object) {
		console.Log("message", obj)
	})
}

About

Package websocket will provide GopherJS bindings for the WebSocket API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Go 100.0%