Documentation ¶
Overview ¶
Package ws implements the Pivo/Websocket connector.
Index ¶
- Constants
- type Conn
- func (c *Conn) BinaryMessage(bin []byte) *pivo.Message
- func (c *Conn) Close(err error) error
- func (c *Conn) Dial(url string, h http.Header) (*Conn, *http.Response, error)
- func (c *Conn) Protocol() string
- func (c *Conn) Receiver(rc pivo.OnReadCloser) error
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) Send(m *pivo.Message) error
- func (c *Conn) Sender() error
- func (c *Conn) TextMessage(text string) *pivo.Message
- func (c *Conn) Upgrade(w http.ResponseWriter, r *http.Request, h http.Header) error
Constants ¶
const DefaultPingTimeout = 60
Default ping timeout value in seconds
const DefaultPortBufferSize = 64
Default port buffer size
const DefaultReadBufferSize = 1024
Default read buffer size
const DefaultWriteBufferSize = 1024
Default write buffer size
const DefaultWriteTimeout = 10
Default write timeout value in seconds
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct { // Ping timeout PingTimeout time.Duration // Write timeout WriteTimeout time.Duration // Port buffer size PortBufferSize int // Those settings are only used by upgraders. // See http://godoc.org/github.com/gorilla/websocket#Upgrader CheckOrigin func(*http.Request) bool ReadBufferSize int WriteBufferSize int // contains filtered or unexported fields }
Conn specifies parameters for this connector.
func DefaultConn ¶
func DefaultConn() *Conn
DefaultConn instantiate a connector with default settings.
func (*Conn) BinaryMessage ¶
BinaryMessage formats a binary message and returns a pointer to it.
func (*Conn) Receiver ¶
Receiver is an event loop that either calls OnCloser if the connection has terminated or OnReader when data has been read from the socket. Reading data from the socket or keeping it alive will not work unless that function is spinning in a goroutine.
Receiver returns whatever error the OnCloser did return.
func (*Conn) RemoteAddr ¶
RemoteAddr returns the IP address of the remote end.
func (*Conn) Send ¶
Send pushes the given message through the port buffer. pivo.ErrPortBufferIsFull is thrown either if the port buffer is not open or if it has reached it's buffer size.
func (*Conn) Sender ¶
Sender reads messages from the port buffer and write them to the socket. Sending data or keeping the socket open will not be possible without spinning that function in a goroutine.
func (*Conn) TextMessage ¶
TextMessage formats a text message and returns a pointer to it.