Documentation
¶
Index ¶
- Constants
- type Config
- type Connection
- type ConnectionManager
- type Hyperion
- func (h *Hyperion) BroadcastBytes(b []byte)
- func (h *Hyperion) BroadcastJSON(v any) error
- func (h *Hyperion) BroadcastString(s string)
- func (h *Hyperion) Dial(url string, header http.Header) (*Connection, *http.Response, error)
- func (h *Hyperion) HandleClose(handler func(*Connection, Message))
- func (h *Hyperion) HandleMessage(handler func(*Connection, Message))
- func (h *Hyperion) Upgrade(w http.ResponseWriter, r *http.Request) (*Connection, error)
- type Message
Constants ¶
View Source
const ( CloseNormalClosure = websocket.CloseNormalClosure CloseGoingAway = websocket.CloseGoingAway CloseProtocolError = websocket.CloseProtocolError CloseUnsupportedData = websocket.CloseUnsupportedData CloseNoStatusReceived = websocket.CloseNoStatusReceived CloseAbnormalClosure = websocket.CloseAbnormalClosure CloseInvalidFramePayloadData = websocket.CloseInvalidFramePayloadData ClosePolicyViolation = websocket.ClosePolicyViolation CloseMessageTooBig = websocket.CloseMessageTooBig CloseMandatoryExtension = websocket.CloseMandatoryExtension CloseInternalServerErr = websocket.CloseInternalServerErr CloseServiceRestart = websocket.CloseServiceRestart CloseTryAgainLater = websocket.CloseTryAgainLater CloseTLSHandshake = websocket.CloseTLSHandshake )
Using defined codes from github.com/gorilla/websocket to make them accessible through this lib Close codes defined in RFC 6455, section 11.7.
View Source
const ( DefaultPingInterval = 15 * time.Second DefaultWriteTimeout = 30 * time.Second DefaultReadTimeout = 30 * time.Second DefaultHandshakeTimeout = 15 * time.Second DefaultReadBufferSize = 1024 DefaultWriteBufferSize = 1024 )
Default values used in hyperion.Default()
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// 0 if connection isn't closed
CloseCode int
// The HTTP request that established the connection
HttpUpgradeRequest *http.Request
// contains filtered or unexported fields
}
func (*Connection) Close ¶ added in v0.1.2
func (c *Connection) Close() error
func (*Connection) IsClosed ¶ added in v0.1.1
func (c *Connection) IsClosed() bool
func (*Connection) WriteBytes ¶
func (c *Connection) WriteBytes(b []byte) error
func (*Connection) WriteJSON ¶
func (c *Connection) WriteJSON(v any) error
func (*Connection) WriteString ¶
func (c *Connection) WriteString(s string) error
type ConnectionManager ¶
type ConnectionManager struct {
// contains filtered or unexported fields
}
type Hyperion ¶
func Default ¶
func Default() *Hyperion
Uses the default configuration, use New() for a custom configuration
func (*Hyperion) BroadcastBytes ¶
func (*Hyperion) BroadcastJSON ¶
func (*Hyperion) BroadcastString ¶
func (*Hyperion) HandleClose ¶
func (h *Hyperion) HandleClose(handler func(*Connection, Message))
Set a function that will be called on close
func (*Hyperion) HandleMessage ¶
func (h *Hyperion) HandleMessage(handler func(*Connection, Message))
Set a function that will be called if a new WebSocket message is received
func (*Hyperion) Upgrade ¶ added in v0.1.1
func (h *Hyperion) Upgrade(w http.ResponseWriter, r *http.Request) (*Connection, error)
Click to show internal directories.
Click to hide internal directories.