Documentation
¶
Index ¶
- Constants
- func NewRequestContext(command RESTCommand, id, sourceCtx int) context.Context
- type RESTCommand
- type Server
- func (s *Server) AddRoom(roomNumber int, initialClientID int)
- func (s *Server) BroadcastToRoom(roomNumber int, payload interface{}, ctx context.Context)
- func (s *Server) DisconnectClient(clientID int)
- func (s *Server) JoinRoom(roomNumber int, userID int)
- func (s *Server) RemoveClientFromRoom(roomNumber int, userID int)
- func (s *Server) RemoveRoom(roomNumber int)
- func (s *Server) StartWebsocket(w http.ResponseWriter, r *http.Request, user int) error
- func (s *Server) Unicast(ctx context.Context, userID int, payload interface{})
- type WebsocketRateLimiter
- type WebsocketVaryBy
Constants ¶
View Source
const ( GetCommandMethod = iota + 1 DeleteCommandMethod PostCommandMethod PatchCommandMethod NotifyCommandMethod ErrorCommandMethod HeartbeatCommandMethod )
View Source
const ( RequestContextCommandKey = "command" RequestContextSourceKey = "Source" RequestContextIDKey = "id" )
Variables ¶
This section is empty.
Functions ¶
func NewRequestContext ¶
func NewRequestContext(command RESTCommand, id, sourceCtx int) context.Context
Types ¶
type RESTCommand ¶
type Server ¶
type Server struct { Messaging messaging.Service Conversations conversations.Service User user.Service // contains filtered or unexported fields }
func (*Server) BroadcastToRoom ¶
BroadcastToRoom sends a RESTCommand with payload to every member of the specified room.
func (*Server) DisconnectClient ¶
func (*Server) JoinRoom ¶
JoinRoom adds a client to a room If either the room or the client does not exist, nothing is done.
func (*Server) RemoveClientFromRoom ¶
RemoveClientFromRoom removes the client with the spcified id from the room. If the client or the room doesn't exist this function does nothing.
func (*Server) RemoveRoom ¶
func (*Server) StartWebsocket ¶
StartWebsocket upgrades the connection to a websocket connection.
type WebsocketRateLimiter ¶
type WebsocketRateLimiter struct { RateLimiter throttled.RateLimiter VaryBy interface { Key(method int, ressource string, remoteAddr string) string } }
func (*WebsocketRateLimiter) RateLimit ¶
func (l *WebsocketRateLimiter) RateLimit(method int, ressource string, remoteAddr string) (error, error)
RateLimit checks if the rate limit for the given citeria was reached. If yes it returns an RequestLimitExceededError error as its first return value. The second returned error is not nil if something went wrong.
type WebsocketVaryBy ¶
Click to show internal directories.
Click to hide internal directories.