sockjsclient

package
v0.0.0-...-c00e064 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2016 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSessionClosed = errors.New("session is closed")

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

Functions

This section is empty.

Types

type DialOptions

type DialOptions struct {
	BaseURL string // required

	ReadBufferSize  int
	WriteBufferSize int
	Timeout         time.Duration
	ClientFunc      func(*DialOptions) *http.Client
}

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

func (*DialOptions) Client

func (opts *DialOptions) Client() *http.Client

Client gives a client to use for making HTTP requests.

If ClientFunc is non-nil it is used to make the requests. Otherwise default client is returned.

type Rand

type Rand struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Rand is a threaSafe rand.Rand type

type WebsocketSession

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

WebsocketSession represents a sockjs.Session over a websocket connection.

func ConnectWebsocketSession

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

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

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) 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) 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
}

func NewXHRSession

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

func (*XHRSession) Close

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

func (*XHRSession) ID

func (x *XHRSession) ID() string

func (*XHRSession) Recv

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

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