Documentation
¶
Index ¶
Constants ¶
const ( TextMessageType = websocket.TextMessage BinaryMessageType = websocket.BinaryMessage )
MessageType constants. these are same websocket package's values.
Variables ¶
var ( // ErrCloseSent is returned when the application writes a message to the // connection after sending a close message. ErrCloseSent = websocket.ErrCloseSent )
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn represents a WebSocket connection.
func Connect ¶
func Connect(ctx context.Context, settings Settings, url string, requestHeader http.Header) (*Conn, *http.Response, error)
Connect to the peer. the requestHeader argument may be nil.
func UpgradeFromHTTP ¶
func UpgradeFromHTTP(ctx context.Context, settings Settings, w http.ResponseWriter, r *http.Request) (*Conn, error)
UpgradeFromHTTP upgrades HTTP to WebSocket.
func (*Conn) SendBinaryMessage ¶
SendBinaryMessage to the peer. This method is goroutine safe.
func (*Conn) SendJSONMessage ¶
SendJSONMessage to the peer. This method is goroutine safe.
func (*Conn) SendTextMessage ¶
SendTextMessage to the peer. This method is goroutine safe.
type DialerSettings ¶
type DialerSettings struct {
NetDial func(network, addr string) (net.Conn, error)
TLSClientConfig *tls.Config
}
DialerSettings represents websocket.Dialer settings.
type Message ¶
type Message struct {
MessageType MessageType
Data []byte
}
Message represents a message.
func (Message) IsBinaryMessage ¶
IsBinaryMessage determines whether the message is a binary message.
func (Message) IsTextMessage ¶
IsTextMessage determines whether the message is a text message.
func (Message) UnmarshalAsJSON ¶
UnmarshalAsJSON unmarshals data as JSON.
type Settings ¶
type Settings struct {
WriteWait time.Duration
PongWait time.Duration
PingPeriod time.Duration
HandshakeTimeout time.Duration
MaxMessageSize int64
ReadBufferSize int
WriteBufferSize int
Subprotocols []string
DialerSettings *DialerSettings
UpgraderSettings *UpgraderSettings
}
Settings represents connection settings.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
hello_world/client
command
|
|
|
hello_world/server
command
|
|
|
simple/client
command
|
|
|
simple/server
command
|
