Documentation

Overview

    Package gosockjs is an concurrent safe implementation of a SockJS server. The core design principles are described here http://blog.igormihalik.com/2012/12/sockjs-for-go.html and source code can be found on github https://github.com/igm/sockjs-go

    Index

    Examples

    Constants

    This section is empty.

    Variables

    View Source
    var DefaultConfig = Config{
    	SockjsUrl:       "http://cdn.sockjs.org/sockjs-0.3.4.min.js",
    	Websocket:       true,
    	ResponseLimit:   128 * 1024,
    	HeartbeatDelay:  time.Duration(25 * time.Second),
    	DisconnectDelay: time.Duration(5 * time.Second),
    	CookieNeeded:    false,
    	DecodeFrames:    false,
    }

      Default Configuration with 128kB response limit

      View Source
      var ErrConnectionClosed = errors.New("Connection closed.")

        Error variable

        Functions

        func Install

        func Install(baseUrl string, h HandlerFunc, cfg Config) http.Handler
        Example
        Output:
        
        

        func NewRouter

        func NewRouter(baseUrl string, h HandlerFunc, cfg Config) http.Handler

          Creates new http.Handler that can be used in http.ServeMux (e.g. http.DefaultServeMux)

          Example
          Output:
          
          

          Types

          type Config

          type Config struct {
          	SockjsUrl       string
          	Websocket       bool
          	ResponseLimit   int
          	HeartbeatDelay  time.Duration
          	DisconnectDelay time.Duration
          	CookieNeeded    bool
          	DecodeFrames    bool
          }

          type Conn

          type Conn interface {
          	// Reads message from the open connection. Or returns error if connection is closed.
          	ReadMessage() ([]byte, error)
          	// Writes message to the open connection. Or returns error if connection is closed.
          	WriteMessage([]byte) (int, error)
          	// Closes open conenction.  Or returns error if connection is already closed.
          	Close() error
          }

            Conn is a sockjs data-frame oriented network connection.

            type HandlerFunc

            type HandlerFunc func(Conn)