link преди 2 години
родител
ревизия
5c2c3b5e98
променени са 1 файла, в които са добавени 2 реда и са изтрити 0 реда
  1. 2 0
      route/v1/file.go

+ 2 - 0
route/v1/file.go

@@ -985,6 +985,7 @@ func init() {
 func (c *Client) writePump() {
 	defer func() {
 		c.handler.unregister <- c
+
 		c.conn.Close()
 	}()
 	for {
@@ -1011,6 +1012,7 @@ func (c *Client) readPump() {
 			if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {
 				log.Printf("error: %v", err)
 			}
+			c.handler.broadcast <- []byte(`{"type":"peer-left","peerId":"` + c.ID + `"}`)
 			break
 		}
 		// 要的话,推给广播中心,广播中心再推给每个用户