Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 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) 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) 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