add and improve remove driver function and rename datapoint
This commit is contained in:
@@ -17,10 +17,10 @@ var Broadcast Clients = make(Clients)
|
||||
|
||||
const (
|
||||
// Time allowed to write a message to the peer.
|
||||
writeWait = 30 * time.Second
|
||||
writeWait = 10 * time.Second
|
||||
|
||||
// Time allowed to read the next pong message from the peer.
|
||||
pongWait = 40 * time.Second
|
||||
pongWait = 30 * time.Second
|
||||
|
||||
// Send pings to peer with this period. Must be less than pongWait.
|
||||
pingPeriod = (pongWait * 9) / 10
|
||||
@@ -69,12 +69,15 @@ func ConnectNewClient(id string, c *gin.Context) (*Client, error) {
|
||||
|
||||
Broadcast[client.Id] = client
|
||||
|
||||
conn.SetReadDeadline(time.Now().Add(pongWait))
|
||||
|
||||
conn.SetPingHandler(func(appData string) error {
|
||||
if client.OnPing != nil {
|
||||
client.OnPing()
|
||||
}
|
||||
|
||||
conn.SetReadDeadline(time.Now().Add(pongWait))
|
||||
conn.SetWriteDeadline(time.Now().Add(writeWait))
|
||||
conn.SetReadDeadline(time.Now().Add(writeWait))
|
||||
if err := client.conn.WriteControl(websocket.PongMessage, []byte(appData), time.Now().Add(pongWait)); err != nil {
|
||||
client.OnError(err)
|
||||
}
|
||||
@@ -166,6 +169,7 @@ func (c *Client) PingInterval(interval time.Duration) {
|
||||
c.OnError(err)
|
||||
return
|
||||
}
|
||||
|
||||
for range ticker.C {
|
||||
if c.OnPing != nil {
|
||||
c.OnPing()
|
||||
|
Reference in New Issue
Block a user