Fix godoc style comments (#356)
This commit is contained in:
committed by
GitHub
parent
8f921fbfde
commit
2e1f8d29b5
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/owncast/owncast/models"
|
||||
)
|
||||
|
||||
//Setup sets up the chat server
|
||||
// Setup sets up the chat server.
|
||||
func Setup(listener models.ChatListener) {
|
||||
setupPersistence()
|
||||
|
||||
@@ -32,7 +32,7 @@ func Setup(listener models.ChatListener) {
|
||||
}
|
||||
}
|
||||
|
||||
//Start starts the chat server
|
||||
// Start starts the chat server.
|
||||
func Start() error {
|
||||
if _server == nil {
|
||||
return errors.New("chat server is nil")
|
||||
@@ -53,7 +53,7 @@ func Start() error {
|
||||
return errors.New("chat server failed to start")
|
||||
}
|
||||
|
||||
//SendMessage sends a message to all
|
||||
// SendMessage sends a message to all.
|
||||
func SendMessage(message models.ChatMessage) {
|
||||
if _server == nil {
|
||||
return
|
||||
@@ -62,7 +62,7 @@ func SendMessage(message models.ChatMessage) {
|
||||
_server.SendToAll(message)
|
||||
}
|
||||
|
||||
//GetMessages gets all of the messages
|
||||
// GetMessages gets all of the messages.
|
||||
func GetMessages() []models.ChatMessage {
|
||||
if _server == nil {
|
||||
return []models.ChatMessage{}
|
||||
|
||||
@@ -44,7 +44,7 @@ const (
|
||||
PONG = "PONG"
|
||||
)
|
||||
|
||||
//NewClient creates a new chat client
|
||||
// NewClient creates a new chat client.
|
||||
func NewClient(ws *websocket.Conn) *Client {
|
||||
if ws == nil {
|
||||
log.Panicln("ws cannot be nil")
|
||||
@@ -63,7 +63,7 @@ func NewClient(ws *websocket.Conn) *Client {
|
||||
return &Client{time.Now(), 0, userAgent, ipAddress, nil, clientID, nil, socketID, ws, ch, pingch, usernameChangeChannel, doneCh}
|
||||
}
|
||||
|
||||
//GetConnection gets the connection for the client
|
||||
// GetConnection gets the connection for the client.
|
||||
func (c *Client) GetConnection() *websocket.Conn {
|
||||
return c.ws
|
||||
}
|
||||
@@ -77,18 +77,18 @@ func (c *Client) Write(msg models.ChatMessage) {
|
||||
}
|
||||
}
|
||||
|
||||
//Done marks the client as done
|
||||
// Done marks the client as done.
|
||||
func (c *Client) Done() {
|
||||
c.doneCh <- true
|
||||
}
|
||||
|
||||
// Listen Write and Read request via chanel
|
||||
// Listen Write and Read request via channel.
|
||||
func (c *Client) Listen() {
|
||||
go c.listenWrite()
|
||||
c.listenRead()
|
||||
}
|
||||
|
||||
// Listen write request via chanel
|
||||
// Listen write request via channel.
|
||||
func (c *Client) listenWrite() {
|
||||
for {
|
||||
select {
|
||||
@@ -110,7 +110,7 @@ func (c *Client) listenWrite() {
|
||||
}
|
||||
}
|
||||
|
||||
// Listen read request via chanel
|
||||
// Listen read request via channel.
|
||||
func (c *Client) listenRead() {
|
||||
for {
|
||||
select {
|
||||
|
||||
@@ -16,7 +16,7 @@ var (
|
||||
_server *server
|
||||
)
|
||||
|
||||
//Server represents the server which handles the chat
|
||||
// Server represents the server which handles the chat.
|
||||
type server struct {
|
||||
Clients map[string]*Client
|
||||
|
||||
@@ -31,27 +31,27 @@ type server struct {
|
||||
errCh chan error
|
||||
}
|
||||
|
||||
//Add adds a client to the server
|
||||
// Add adds a client to the server.
|
||||
func (s *server) add(c *Client) {
|
||||
s.addCh <- c
|
||||
}
|
||||
|
||||
//Remove removes a client from the server
|
||||
// Remove removes a client from the server.
|
||||
func (s *server) remove(c *Client) {
|
||||
s.delCh <- c
|
||||
}
|
||||
|
||||
//SendToAll sends a message to all of the connected clients
|
||||
// SendToAll sends a message to all of the connected clients.
|
||||
func (s *server) SendToAll(msg models.ChatMessage) {
|
||||
s.sendAllCh <- msg
|
||||
}
|
||||
|
||||
//Done marks the server as done
|
||||
// Done marks the server as done.
|
||||
func (s *server) done() {
|
||||
s.doneCh <- true
|
||||
}
|
||||
|
||||
//Err handles an error
|
||||
// Err handles an error.
|
||||
func (s *server) err(err error) {
|
||||
s.errCh <- err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user