hsson / gows

Easy to use Websocket server abstraction for Go (Golang)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hsson/gows (Go Websocket)

PkgGoDev GoReportCard

Websocket servers in Go (Golang) made simple!

gows is a high-level abstraction of a Websocket server that hides away all the boring an complicated details of dealing with a websocket connection. Under the hood, the gorilla/websocket package is used. When using gows, Ping/Pong is automatically handled and you can read and write messages with ease.

Example

The following is an example of a websocket server that simply echoes whatever is being sent from the client:

func echo(w http.ResponseWriter, r *http.Request) {
	ws, err := gows.Upgrade(w, r)
	if err != nil {
		// error handling...
	}

	for {
		msg := <-ws.Read()
		ws.WriteText(msg.Data)
	}
}

About

Easy to use Websocket server abstraction for Go (Golang)

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Go 100.0%