sockjs-go

WebSocket emulation - Go server library

  • 所有者: igm/sockjs-go
  • 平台:
  • 许可证: BSD 3-Clause "New" or "Revised" License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

Build Status GoDoc Coverage Status

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 library

SockJS-Go is a SockJS server library written in Go.

To use current stable version v2

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

To use previous version v1 (DEPRECATED)

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

To install development version of sockjs-go run:

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

Versioning

SockJS-Go project adopted gopkg.in approach for versioning. SockJS-Go library details can be found here

Example

A simple echo sockjs server:

package main

import (
	"log"
	"net/http"

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

func main() {
	handler := sockjs.NewHandler("/echo", sockjs.DefaultOptions, echoHandler) 
	log.Fatal(http.ListenAndServe(":8081", handler))
}

func echoHandler(session sockjs.Session) {
	for {
		if msg, err := session.Recv(); err == nil {
			session.Send(msg)
			continue
		}
		break
	}
}

SockJS Protocol Tests Status

SockJS defines a set of protocol tests to quarantee a server compatibility with sockjs client library and various browsers. SockJS-Go server library aims to provide full compatibility, however there are couple of tests that don't and probably will never pass due to reasons explained in table below:, Failing Test, Explanation, -------------, ------------, XhrPolling.test_transport, does not pass due to a feature in net/http that does not send content-type header in case of StatusNoContent response code (even if explicitly set in the code), details, WebSocket., Sockjs Go version supports RFC 6455, draft protocols hixie-76, hybi-10 are not supported, JSONEncoding, As menioned in browser quirks section: "it's advisable to use only valid characters. Using invalid characters is a bit slower, and may not work with SockJS servers that have a proper Unicode support." Go lang has a proper Unicode support, RawWebsocket., The sockjs protocol tests use old WebSocket client library (hybi-10) that does not support RFC 6455 properly, WebSocket

As mentioned above sockjs-go library is compatible with RFC 6455. That means the browsers not supporting RFC 6455 are not supported properly. There are no plans to support draft versions of WebSocket protocol. The WebSocket support is based on Gorilla web toolkit implementation of WebSocket.

For detailed information about browser versions supporting RFC 6455 see this wiki page.

主要指标

概览
名称与所有者igm/sockjs-go
主编程语言Go
编程语言Go (语言数: 1)
平台
许可证BSD 3-Clause "New" or "Revised" License
所有者活动
创建于2012-11-23 11:43:21
推送于2023-11-08 07:15:41
最后一次提交2023-11-08 04:14:37
发布数8
最新版本名称v3.0.3 (发布于 )
第一版名称v1.0.0 (发布于 )
用户参与
星数515
关注者数24
派生数99
提交数275
已启用问题?
问题数41
打开的问题数4
拉请求数45
打开的拉请求数2
关闭的拉请求数20
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?