sockjs-go

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2014 License: BSD-3-Clause

README

What is SockJS?

SockJS is a JavaScript library (for browsers) that provides a WebSocket-like object. SockJS gives you a coherent, cross-browser, Javascript API which creates a low latency, full duplex, cross-domain communication channel between the browser and the web server, with WebSockets or without. This necessitates the use of a server, which this is one version of, for GO.

SockJS-Go server

SockJS-Go is a SockJS server written in Go.

To install sockjs-go run:

go get gopkg.in/igm/sockjs-go.v1/sockjs

Versioning

SockJS-Go project adopted gopkg.in approach for versioning. Current development version is v0 which "is equivalent to labeling the package as alpha or beta quality, and as such the use of these packages as dependencies of stable packages and applications is discouraged". This means that version 0.x.x denotes "master" and various API changes might and will be introduced here.

For stable version use v1, which will not break current API:

go get gopkg.in/igm/sockjs-go.v1/sockjs

A simplified echo SockJS server could look more or less like:

package main

import (
	"log"
	"net/http"

	"gopkg.in/igm/sockjs-go.v1/sockjs"
)

func main() {
    sockjs.Install("/echo", EchoHandler, sockjs.DefaultConfig)
	err := http.ListenAndServe(":8080", nil)
	log.Fatal(err)
}

func EchoHandler(conn sockjs.Conn) {
	for {
		if msg, err := conn.ReadMessage(); err == nil {
			go conn.WriteMessage(msg)
		} else {
			return
		}
	}
}

SockJS Protocol Tests Status

ERROR: test_haproxy (__main__.WebsocketHixie76)
ERROR: test_firefox_602_connection_header (__main__.WebsocketHybi10)
ERROR: test_headersSanity (__main__.WebsocketHybi10)
FAIL: test_streaming (__main__.Http10)

Ran 68 tests in 1.441s
FAILED (failures=1, errors=3)

Important

This library is not production ready and use is not recommended.

Directories

Path Synopsis
examples
Package gosockjs is an concurrent safe implementation of a SockJS server.
Package gosockjs is an concurrent safe implementation of a SockJS server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL