sockjsclient

package
v0.0.0-...-1b13e06 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2017 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
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.

Functions

func IsSessionClosed

func IsSessionClosed(err error) bool

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

Types

type DialOptions deprecated

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

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

func (err *ErrSession) Error() string

Error implements the buildin error interface.

type WebsocketSession

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

WebsocketSession represents a sockjs.Session over a websocket connection.

func ConnectWebsocketSession deprecated

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

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

func NewWebsocketSession(conn *websocket.Conn) *WebsocketSession

NewWebsocketSession creates new sockjs.Session from existing websocket connection.

func (*WebsocketSession) Close

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

Close closes the session with provided code and reason.

func (*WebsocketSession) GetSessionState

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

GetSessionState gives state of the session.

func (*WebsocketSession) ID

func (w *WebsocketSession) ID() string

ID returns a session id.

func (*WebsocketSession) Recv

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

Recv reads one text frame from session.

func (*WebsocketSession) RemoteAddr

func (w *WebsocketSession) RemoteAddr() string

RemoteAddr gives network address of the remote client.

func (*WebsocketSession) Request

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

Request implements the sockjs.Session interface.

func (*WebsocketSession) Send

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

Send sends one text frame to session

type XHRSession

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

XHRSession implements sockjs.Session with XHR transport.

func DialXHR

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 deprecated

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

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

func (*XHRSession) GetSessionState

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

GetSessionState gives state of the session.

func (*XHRSession) ID

func (x *XHRSession) ID() string

func (*XHRSession) Recv

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

func (*XHRSession) Request

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

Request implements the sockjs.Session interface.

func (*XHRSession) Send

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

Jump to

Keyboard shortcuts

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