Documentation ¶
Index ¶
- type CastType
- type Client
- type ClientID
- type Conn
- type EventHandler
- type EventHandlers
- type EventMessage
- type EventType
- type MessageHandler
- type MessageHandlerID
- type MessageHandlers
- type RequestMessage
- type ResponseMessage
- type ResponseMessages
- type Server
- func (m *Server) Listen()
- func (m *Server) NewClient(conn Conn) *Client
- func (m *Server) OnAddClient(c *Client)
- func (m *Server) OnBroadCast(msg *ResponseMessage)
- func (m *Server) OnDelClient(c *Client)
- func (m *Server) OnDone()
- func (m *Server) OnEnqueueMessage(msg *RequestMessage)
- func (m *Server) OnError(err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { ID ClientID // contains filtered or unexported fields }
func (*Client) OnSend ¶
func (m *Client) OnSend(msg *ResponseMessage)
type Conn ¶
type Conn interface { Send(*ResponseMessage) error Receive() (*RequestMessage, error) Close() error }
type EventHandler ¶
type EventHandler func(msg *EventMessage, ctx context.Context) (ResponseMessages, error)
type EventHandlers ¶
type EventHandlers map[EventType]EventHandler
type EventMessage ¶
func NewEventMessage ¶
func NewEventMessage(et EventType, cid ClientID) *EventMessage
type MessageHandler ¶
type MessageHandler func(msg *RequestMessage, ctx context.Context) (ResponseMessages, error)
type MessageHandlerID ¶
type MessageHandlerID int
type MessageHandlers ¶
type MessageHandlers map[MessageHandlerID]MessageHandler
type RequestMessage ¶
type RequestMessage struct { SenderID ClientID HandlerID MessageHandlerID Body []byte }
type ResponseMessage ¶
type ResponseMessage struct { SenderID ClientID EventType EventType HandlerID MessageHandlerID CastType CastType CastFor []ClientID Body []byte }
func NewResponseMessage ¶
func NewResponseMessage(ct CastType, body []byte, cf ...ClientID) *ResponseMessage
type ResponseMessages ¶
type ResponseMessages []*ResponseMessage
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(ctx context.Context, messageHandlers MessageHandlers, eventHandlers EventHandlers) *Server
func (*Server) OnAddClient ¶
func (*Server) OnBroadCast ¶
func (m *Server) OnBroadCast(msg *ResponseMessage)
func (*Server) OnDelClient ¶
func (*Server) OnEnqueueMessage ¶
func (m *Server) OnEnqueueMessage(msg *RequestMessage)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.