Documentation ¶
Index ¶
- func NewRelayServer(config *config.RelayConfig, wsServer *WsServer) *relayServer
- type ClientUnregisterEvent
- type MessageType
- type PhaseType
- type RoleType
- type SocketMessage
- type TopicClientSet
- func (ts *TopicClientSet) Clear(topic string)
- func (ts *TopicClientSet) Get(topic string) map[*client]struct{}
- func (ts *TopicClientSet) GetTopicsByClient(c *client, clear bool) []string
- func (ts *TopicClientSet) Len(topic string) int
- func (ts *TopicClientSet) Set(topic string, c *client)
- func (ts *TopicClientSet) Unset(topic string, c *client)
- type TopicSet
- type WsMessageHandler
- type WsServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRelayServer ¶
func NewRelayServer(config *config.RelayConfig, wsServer *WsServer) *relayServer
Types ¶
type ClientUnregisterEvent ¶
type ClientUnregisterEvent struct {
// contains filtered or unexported fields
}
type MessageType ¶
type MessageType string
const ( Pub MessageType = "pub" Sub MessageType = "sub" Ack MessageType = "ack" Ping MessageType = "ping" Pong MessageType = "pong" )
type SocketMessage ¶
type SocketMessage struct { Topic string `json:"topic"` Type MessageType `json:"type"` // pub, sub, ack Payload string `json:"payload"` Role string `json:"role"` Phase string `json:"phase"` Silent bool `json:"silent"` // contains filtered or unexported fields }
websocket message
func (SocketMessage) MarshalBinary ¶
func (sm SocketMessage) MarshalBinary() ([]byte, error)
type TopicClientSet ¶
TopicClientSet stores topic -> clients relationship
func NewTopicClientSet ¶
func NewTopicClientSet() *TopicClientSet
func (*TopicClientSet) Clear ¶
func (ts *TopicClientSet) Clear(topic string)
func (*TopicClientSet) Get ¶
func (ts *TopicClientSet) Get(topic string) map[*client]struct{}
func (*TopicClientSet) GetTopicsByClient ¶
func (ts *TopicClientSet) GetTopicsByClient(c *client, clear bool) []string
GetTopicsByClient returns the topics associated with the specified client, meanwhile, remove the client from these topics if `clear` is true returns the topics the client has associated with
func (*TopicClientSet) Len ¶
func (ts *TopicClientSet) Len(topic string) int
func (*TopicClientSet) Set ¶
func (ts *TopicClientSet) Set(topic string, c *client)
func (*TopicClientSet) Unset ¶
func (ts *TopicClientSet) Unset(topic string, c *client)
type TopicSet ¶
func NewTopicSet ¶
func NewTopicSet() *TopicSet
func (TopicSet) MarshalLogArray ¶
func (tm TopicSet) MarshalLogArray(encoder zapcore.ArrayEncoder) error
type WsMessageHandler ¶
type WsMessageHandler func(*WsServer, SocketMessage)
type WsServer ¶
type WsServer struct {
// contains filtered or unexported fields
}
func NewWSServer ¶
func (*WsServer) GetDappPublisher ¶
GetDappPulisher gets the topic publisher and check whether its role is "dapp" the return value indicates whether the notification target has been found
func (*WsServer) GetSubscriber ¶
func (*WsServer) NewClientConn ¶
func (ws *WsServer) NewClientConn(w http.ResponseWriter, r *http.Request)
Click to show internal directories.
Click to hide internal directories.