Documentation ¶
Overview ¶
Package socketio implements a client for SocketIO protocol as specified in https://github.com/LearnBoost/socket.io-spec
Index ¶
- type Endpoint
- type Message
- func NewACK(data string) *Message
- func NewConnect(endpoint *Endpoint) *Message
- func NewDisconnect() *Message
- func NewError(endpoint *Endpoint, reason string, advice string) *Message
- func NewEvent(endpoint *Endpoint, name string, args string) *Message
- func NewHeartbeat() *Message
- func NewJSONMessage(endpoint *Endpoint, data string) *Message
- func NewMessageMsg(endpoint *Endpoint, msg string) *Message
- func NewNoop() *Message
- type Session
- type Socket
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Endpoint ¶
Endpoint is a socket.io endpoint.
func NewEndpoint ¶
NewEndpoint returns a new Endpoint with the given path and query.
func ParseEndpoint ¶
ParseEndpoint parses the given rawn endpoint into an Endpoint.
type Message ¶
func NewConnect ¶
NewConnect returns a new connect Message for the given endpoint.
func NewError ¶
NewError returns a new error Message for the given endpoint with a reason and an advice.
func NewJSONMessage ¶
func NewMessageMsg ¶
type Session ¶
type Session struct { ID string HeartbeatTimeout time.Duration ConnectionTimeout time.Duration SupportedProtocols []string }
Session holds the configuration variables received from the socket.io server.
func NewSession ¶
NewSession receives the configuraiton variables from the socket.io server.
func (*Session) SupportProtocol ¶
SupportProtocol checks if the given protocol is supported by the socket.io server.
type Socket ¶
func Dial ¶
Dial opens a new client connection to the socket.io server using one of the implemented and supported Transports.
Example ¶
socket, err := Dial("localhost:12345") if err != nil { panic(err) } for { msg, err := socket.Receive() if err != nil { panic(err) } fmt.Println(msg) }
Output:
func DialAndConnect ¶
Dial opens a new client connection to the socket.io server then connects to the given channel.
Example ¶
socket, err := DialAndConnect("localhost:12345", "/channel", "key=value") if err != nil { panic(err) } for { msg, err := socket.Receive() if err != nil { panic(err) } fmt.Println(msg) }
Output: