Documentation ¶
Index ¶
- Constants
- type Handler
- func (h *Handler) DeregisterClient(conn connection.Connection) error
- func (h *Handler) HandleClientConnection(conn connection.Connection)
- func (h *Handler) ParseCommandMessage(client *client.Client, data connection.MessageData) (string, bool, error)
- func (h *Handler) ParseMessageMedia(data connection.MessageData) ([]string, error)
- func (h *Handler) RegisterClient(conn connection.Connection)
- func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
Constants ¶
const ( ROOM_DEFAULT_STREAMSYNC_RATE = 10 // seconds to wait before emitting streamsync to clients ROOM_DEFAULT_STREAMSYNC_LOGGING_RATE = 50 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct { CommandHandler cmd.SocketCommandHandler PlaybackHandler playback.PlaybackHandler StreamHandler stream.StreamHandler // contains filtered or unexported fields }
func NewHandler ¶
func NewHandler(nsHandler connection.NamespaceHandler, connHandler connection.ConnectionHandler, commandHandler cmd.SocketCommandHandler, clientHandler client.SocketClientHandler, playbackHandler playback.PlaybackHandler, streamHandler stream.StreamHandler) *Handler
func (*Handler) DeregisterClient ¶
func (h *Handler) DeregisterClient(conn connection.Connection) error
func (*Handler) HandleClientConnection ¶
func (h *Handler) HandleClientConnection(conn connection.Connection)
func (*Handler) ParseCommandMessage ¶
func (h *Handler) ParseCommandMessage(client *client.Client, data connection.MessageData) (string, bool, error)
ParseCommandMessage receives a client pointer and a data map sent by a client and determines whether the "message" field in the client data map contains a valid client command. An error is returned if there are any errors while parsing the message field. A boolean (true) is returned if the message field contains a valid client command, along with a string ("command") containing a StreamCommand id
A valid client command will always begin with a "/" and never contain more than one "/" character.
func (*Handler) ParseMessageMedia ¶
func (h *Handler) ParseMessageMedia(data connection.MessageData) ([]string, error)
ParseMessageMedia receives connection.MessageData and parses image urls in the "message" key, removing urls from the text message, and returning them as a slice of strings
func (*Handler) RegisterClient ¶
func (h *Handler) RegisterClient(conn connection.Connection)
RegisterClient receives a socket connection, creates a new client, and assigns the client to a room. if client is first to join room, then the room did not exist before; if this is the case, a new streamPlayback object is created to represent the "room" in memory. The streamPlayback's id becomes the client's room name. If a streamPlayback already exists for the current "room" and the streamPlayback has a reference to a stream.Stream, a "streamload" event is sent to the client with the current stream.Stream information. This method is not concurrency-safe.