Documentation ¶
Index ¶
- func NextId() uint64
- func ReadJsonMessages(r io.Reader, sleepDuration time.Duration, emitter chan RpcMessage) error
- func ReadJsonMessagesFromFile(fn string, sleepDuration time.Duration, emitter chan RpcMessage)
- type Connection
- type Hub
- type RpcError
- type RpcMessage
- type RpcMessageHandler
- type RpcParams
- type RpcRequest
- type RpcRequestHandler
- type RpcResponse
- type RpcSender
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadJsonMessages ¶
func ReadJsonMessagesFromFile ¶
func ReadJsonMessagesFromFile(fn string, sleepDuration time.Duration, emitter chan RpcMessage)
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func NewConnection ¶
func NewConnection(server *Hub, conn *websocket.Conn) *Connection
func (*Connection) BroadCast ¶
func (c *Connection) BroadCast(m RpcMessage)
func (*Connection) Send ¶
func (c *Connection) Send(m RpcMessage)
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
func NewHub ¶
func NewHub(writer RpcRequestHandler) *Hub
func (*Hub) HandleWebsocketRequest ¶
func (h *Hub) HandleWebsocketRequest(w http.ResponseWriter, r *http.Request)
func (*Hub) SendMessage ¶
func (h *Hub) SendMessage(m RpcMessage)
type RpcMessage ¶
type RpcMessage 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 MakeError ¶
func MakeError(code int, msg string) RpcMessage
func MakeNotify ¶
func MakeNotify(method string, params map[string]any) RpcMessage
func MakeResult ¶
func MakeResult(id uint64, result any) RpcMessage
type RpcMessageHandler ¶
type RpcMessageHandler interface {
HandleMessage(m RpcMessage) error
}
type RpcRequest ¶
type RpcRequest struct { Msg RpcMessage Conn *Connection }
type RpcRequestHandler ¶
type RpcRequestHandler interface {
HandleMessage(m RpcRequest) error
}
type RpcResponse ¶
type RpcResponse struct {
Msg RpcMessage
}
type RpcSender ¶
type RpcSender struct {
// contains filtered or unexported fields
}
func NewRpcSender ¶
func NewRpcSender(writer RpcMessageHandler) *RpcSender
func (*RpcSender) SendMessages ¶
func (s *RpcSender) SendMessages(emitter chan RpcMessage)
Click to show internal directories.
Click to hide internal directories.