Documentation ¶
Index ¶
- Constants
- Variables
- func IsNotConnected(err error) bool
- type Client
- func (c *Client) Close() error
- func (c *Client) Conn() Conn
- func (c *Client) Connect() error
- func (c *Client) ConnectContext(ctx context.Context) error
- func (c *Client) IsWebsocket() bool
- func (c *Client) ReadJSON(v interface{}) error
- func (c *Client) ReadMsg() ([]byte, error)
- func (c *Client) ServerInfo() ServerInfo
- func (c *Client) WriteJSON(v interface{}) error
- func (c *Client) WriteMsg(msg []byte) error
- type Conn
- type MessageType
- type ServerInfo
- type WSDialer
- type XHRDialer
Constants ¶
View Source
const ( MessageTypeUnhandled = MessageType(iota) MessageTypeHeartbeat = MessageType(iota) MessageTypeData = MessageType(iota) MessageTypeOpen = MessageType(iota) MessageTypeClose = MessageType(iota) )
Sockjs message types (0th represents any unhandled, treated as error)
Variables ¶
View Source
var ( ErrClientNotConnected = errors.New("sockjsclient: client not connected") ErrClientCannotConnect = errors.New("sockjsclient: client cannot connect") ErrClientCannotDecode = errors.New("sockjsclient: client cannot decode") )
Sockjs client error messages
View Source
var ( ErrClosedConnection = errors.New("sockjsclient: use of a closed connection") ErrClosedByRemote = errors.New("sockjsclient: connection closed by remote") ErrClosingConnection = errors.New("sockjsclient: error closing connection") ErrInvalidResponse = errors.New("sockjsclient: invalid server response") ErrUnexpectedResponse = errors.New("sockjsclient: unexpected server response") ErrNoHeartbeat = errors.New("sockjsclient: no heartbeat") )
Sockjs client connection error messages
Functions ¶
func IsNotConnected ¶
IsNotConnected will return if this is a client / conn not connected error
Types ¶
type Client ¶
type Client struct { // Address is the base server address to connection Address string // ServerID is the server ID string to be used in generation of the transport address ServerID string // SessionID is the session ID string to be used in generation of the transport address SessionID string // Header defines any HTTP headers to provide on first connect Header http.Header // WSDialer provides configuration for dialing WS connections WSDialer *WSDialer // XHRDialer provides configuration for dialing XHR connections XHRDialer *XHRDialer // NoWebsocket indicates whether to prefer XHR connection over WS NoWebsocket bool // contains filtered or unexported fields }
func (*Client) IsWebsocket ¶
IsWebsocket returns whether current connection is via websocket
func (*Client) ReadJSON ¶
ReadJSON will read next message from the sockjs connection and attempt JSON decode into "v"
func (*Client) ServerInfo ¶
func (c *Client) ServerInfo() ServerInfo
ServerInfo returns ServerInfo related to current conn (empty if not connected)
type Conn ¶
type Conn interface { // ReadMsg reads the next single data message from the sockjs connection ReadMsg() ([]byte, error) // WriteMsg writes a block of data messages to the sockjs connection WriteMsg(...[]byte) error // Close will close the sockjs connection Close() error }
Conn represents a sockjs client connection
type ServerInfo ¶
type ServerInfo struct { WebSocket bool `json:"websocket"` CookieNeeded bool `json:"cookie_needed"` Origins []string `json:"origins"` Entropy int `json:"entropy"` }
ServerInfo representations an "/info" response from a sockjs server
func GetServerInfo ¶
func GetServerInfo(addr string) (*ServerInfo, *url.URL, error)
GetServerInfo attempts to fetch sockjs ServerInfo for given address and parse server addr
type WSDialer ¶
type WSDialer struct { // Dialer is the underlying websocket dialer used // by the produced websocket conn Dialer *websocket.Dialer }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.