Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MessageFromJson ¶ added in v0.8.0
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection represents a cancelable websocket connection.
func Dial ¶ added in v0.8.0
func Dial(ctx context.Context, url string) (*Connection, error)
Dial creates a new client connection. It tries repeatedly to connect to the server until successful or context is done.
func NewConnection ¶
func NewConnection(ctx context.Context, socket *websocket.Conn) *Connection
NewConnection handles a new websocket
func (*Connection) Close ¶ added in v0.8.0
func (c *Connection) Close()
Close closes the connection and the underlying socket.
func (*Connection) Done ¶ added in v0.8.0
func (c *Connection) Done() <-chan struct{}
Done returns a channel that is closed when the connection is closed.
func (*Connection) Id ¶ added in v0.8.0
func (c *Connection) Id() string
Id returns the connection id.
func (*Connection) Read ¶ added in v0.8.0
func (c *Connection) Read() []byte
func (*Connection) ReadJSON ¶ added in v0.8.0
func (c *Connection) ReadJSON(v interface{}) error
func (*Connection) Write ¶ added in v0.8.0
func (c *Connection) Write(data []byte)
func (*Connection) WriteJSON ¶ added in v0.8.0
func (c *Connection) WriteJSON(v interface{}) error
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
func (*Hub) BroadcastJSON ¶ added in v0.8.0
BroadcastJSON encodes v as JSON and broadcasts it to all connections.
type Message ¶ added in v0.8.0
type Message struct { Version string `json:"version"` Method string `json:"method"` Id uint64 `json:"id"` Params map[string]any `json:"params"` Result any `json:"result"` Error RpcError `json:"error,omitempty"` }
func MakeResult ¶
type MessageHandler ¶ added in v0.8.0
type Request ¶ added in v0.8.0
type Request struct {
// contains filtered or unexported fields
}
Request represents a request from a client.
func (Request) BroadcastJSON ¶ added in v0.8.0
BroadcastJSON encodes v as JSON and broadcasts it to all connections.
func (Request) Error ¶ added in v0.8.0
Error returns the error that occurred while processing the request.
type RequestHandler ¶ added in v0.8.0
Click to show internal directories.
Click to hide internal directories.