Created
September 11, 2022 06:01
-
-
Save percybolmer/1975c15ddcf9976120627b5262937abe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// readMessages will start the client to read messages and handle them | |
// appropriatly. | |
// This is suppose to be ran as a goroutine | |
func (c *Client) readMessages() { | |
defer func() { | |
// Graceful Close the Connection once this | |
// function is done | |
c.manager.removeClient(c) | |
}() | |
// Set Max Size of Messages in Bytes | |
c.connection.SetReadLimit(512) | |
// Configure Wait time for Pong response, use Current time + pongWait | |
// This has to be done here to set the first initial timer. | |
if err := c.connection.SetReadDeadline(time.Now().Add(pongWait)); err != nil { | |
log.Println(err) | |
return | |
} | |
// Configure how to handle Pong responses | |
c.connection.SetPongHandler(c.pongHandler) | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment