mirror of
https://github.com/owncast/owncast.git
synced 2024-11-25 06:12:23 +03:00
Cleanup some exported methods
This commit is contained in:
parent
3c7997b75e
commit
bda430f791
2 changed files with 5 additions and 15 deletions
|
@ -69,12 +69,7 @@ func NewClient(ws *websocket.Conn) *Client {
|
|||
return &Client{time.Now(), 0, userAgent, ipAddress, nil, clientID, nil, socketID, ws, ch, pingch, usernameChangeChannel, doneCh, rateLimiter}
|
||||
}
|
||||
|
||||
// GetConnection gets the connection for the client.
|
||||
func (c *Client) GetConnection() *websocket.Conn {
|
||||
return c.ws
|
||||
}
|
||||
|
||||
func (c *Client) Write(msg models.ChatEvent) {
|
||||
func (c *Client) write(msg models.ChatEvent) {
|
||||
select {
|
||||
case c.ch <- msg:
|
||||
default:
|
||||
|
@ -83,13 +78,8 @@ func (c *Client) Write(msg models.ChatEvent) {
|
|||
}
|
||||
}
|
||||
|
||||
// Done marks the client as done.
|
||||
func (c *Client) Done() {
|
||||
c.doneCh <- true
|
||||
}
|
||||
|
||||
// Listen Write and Read request via channel.
|
||||
func (c *Client) Listen() {
|
||||
func (c *Client) listen() {
|
||||
go c.listenWrite()
|
||||
c.listenRead()
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ func (s *server) err(err error) {
|
|||
|
||||
func (s *server) sendAll(msg models.ChatEvent) {
|
||||
for _, c := range s.Clients {
|
||||
c.Write(msg)
|
||||
c.write(msg)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ func (s *server) onConnection(ws *websocket.Conn) {
|
|||
}()
|
||||
|
||||
s.add(client)
|
||||
client.Listen()
|
||||
client.listen()
|
||||
}
|
||||
|
||||
// Listen and serve.
|
||||
|
@ -154,6 +154,6 @@ func (s *server) sendWelcomeMessageToClient(c *Client) {
|
|||
|
||||
initialChatMessageText := fmt.Sprintf("Welcome to %s! %s", config.Config.InstanceDetails.Title, config.Config.InstanceDetails.Summary)
|
||||
initialMessage := models.ChatEvent{ClientID: "owncast-server", Author: config.Config.InstanceDetails.Name, Body: initialChatMessageText, ID: "initial-message-1", MessageType: "SYSTEM", Visible: true, Timestamp: time.Now()}
|
||||
c.Write(initialMessage)
|
||||
c.write(initialMessage)
|
||||
}()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue