kite: github.com/koding/kite/sockjsclient Index | Files

package sockjsclient

import "github.com/koding/kite/sockjsclient"

Index

Package Files

sockjsclient.go xhr.go

Variables

var ErrPollTimeout = errors.New("polling on XHR response has timed out")

ErrPollTimeout is returned when reading first byte of the http response body has timed out.

It is an fatal error when waiting for the session open frame ('o').

After the session is opened, the error makes the poller retry polling.

var ErrSessionClosed = &ErrSession{
    State: sockjs.SessionClosed,
}

ErrSessionClosed is returned by Send/Recv methods when calling them after the session got closed.

Deprecated: Send/Recv methods return *ErrSession error with State set to sockjs.SessionClosed instead.

func IsSessionClosed Uses

func IsSessionClosed(err error) bool

IsSessionClosed tests whether given error is caused by a closed session.

type DialOptions Uses

type DialOptions struct {
    // URL of the remote kite.
    //
    // Required.
    BaseURL string

    // ReadBufferSize is the buffer size used for
    // reads on a websocket connection.
    //
    // Deprecated: Set Config.Dialer.ReadBufferSize of
    // the local kite instead.
    ReadBufferSize int

    // WriteBufferSize is the buffer size used for
    // writes on a websocket connection.
    //
    // Deprecated: Set Config.Dialer.WriteBufferSize of the
    // the local kite instead.
    WriteBufferSize int

    // Timeout specifies dial timeout
    //
    // Deprecated: Set Config.Dialer.Dial of the local kite instead.
    Timeout time.Duration

    // ClientFunc gives new HTTP client for use with XHR connections.
    //
    // Deprecated: Set Config.ClientFunc of the local kite instead.
    ClientFunc func(*DialOptions) *http.Client
}

DialOptions are used to overwrite default behavior of the websocket session.

Deprecated: Use *config.Config struct instead for configuring SockJS connection.

type ErrSession Uses

type ErrSession struct {
    Type  config.Transport
    State sockjs.SessionState // session state
    Err   error               // more detailed description of the problem
}

ErrSession is returned by Send/Recv methods when the underlying session state change is responsible for the failure.

func (*ErrSession) Error Uses

func (err *ErrSession) Error() string

Error implements the buildin error interface.

type WebsocketSession Uses

type WebsocketSession struct {
    // contains filtered or unexported fields
}

WebsocketSession represents a sockjs.Session over a websocket connection.

func ConnectWebsocketSession Uses

func ConnectWebsocketSession(opts *DialOptions) (*WebsocketSession, error)

ConnectWebsocketSession dials the remote specified in the opts and creates new websocket session.

Deprecated: Use DialWebsocket instead.

func DialWebsocket Uses

func DialWebsocket(uri string, cfg *config.Config) (*WebsocketSession, error)

DialWebsocket establishes a SockJS session over a websocket connection.

Requires cfg.Websocket to be a valid client.

func NewWebsocketSession Uses

func NewWebsocketSession(conn *websocket.Conn) *WebsocketSession

NewWebsocketSession creates new sockjs.Session from existing websocket connection.

func (*WebsocketSession) Close Uses

func (w *WebsocketSession) Close(uint32, string) error

Close closes the session with provided code and reason.

func (*WebsocketSession) GetSessionState Uses

func (w *WebsocketSession) GetSessionState() sockjs.SessionState

GetSessionState gives state of the session.

func (*WebsocketSession) ID Uses

func (w *WebsocketSession) ID() string

ID returns a session id.

func (*WebsocketSession) Recv Uses

func (w *WebsocketSession) Recv() (string, error)

Recv reads one text frame from session.

func (*WebsocketSession) RemoteAddr Uses

func (w *WebsocketSession) RemoteAddr() string

RemoteAddr gives network address of the remote client.

func (*WebsocketSession) Request Uses

func (w *WebsocketSession) Request() *http.Request

Request implements the sockjs.Session interface.

func (*WebsocketSession) Send Uses

func (w *WebsocketSession) Send(str string) error

Send sends one text frame to session

type XHRSession Uses

type XHRSession struct {
    // contains filtered or unexported fields
}

XHRSession implements sockjs.Session with XHR transport.

func DialXHR Uses

func DialXHR(uri string, cfg *config.Config) (*XHRSession, error)

DialXHR establishes a SockJS session over a XHR connection.

Requires cfg.XHR to be a valid client.

func NewXHRSession Uses

func NewXHRSession(opts *DialOptions) (*XHRSession, error)

NewXHRSession returns a new XHRSession, a SockJS client which supports xhr-polling:

http://sockjs.github.io/sockjs-protocol/sockjs-protocol-0.3.3.html#section-74

Deprecated: Use DialXHR instead.

func (*XHRSession) Close Uses

func (x *XHRSession) Close(status uint32, reason string) error

func (*XHRSession) GetSessionState Uses

func (x *XHRSession) GetSessionState() sockjs.SessionState

GetSessionState gives state of the session.

func (*XHRSession) ID Uses

func (x *XHRSession) ID() string

func (*XHRSession) Recv Uses

func (x *XHRSession) Recv() (string, error)

func (*XHRSession) Request Uses

func (x *XHRSession) Request() *http.Request

Request implements the sockjs.Session interface.

func (*XHRSession) Send Uses

func (x *XHRSession) Send(frame string) error

Package sockjsclient imports 18 packages (graph) and is imported by 11 packages. Updated 2017-04-06. Refresh now. Tools for package owners.