Skip to content

eidmanna/sockjs-go

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 Node.js server side counterpart of SockJS-client browser library written in CoffeeScript.

To install sockjs-go run:

go get github.com/igm/sockjs-go/sockjs

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

package main

import (
	"github.com/igm/sockjs-go/sockjs"
	"log"
	"net/http"
)

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.

About

WebSocket emulation - Go server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published