closing now properly the connection
parent
23d1d9dd1d
commit
c4e964e115
|
@ -56,7 +56,7 @@ func (p *PSCli) GetConn() *websocket.Conn {
|
|||
p.con = con
|
||||
p.con.SetCloseHandler(func(code int, text string) error {
|
||||
log.Printf("Connection closed: %d: %s", code, text)
|
||||
p.con = nil
|
||||
p.Close()
|
||||
return nil
|
||||
})
|
||||
break
|
||||
|
@ -98,7 +98,9 @@ func (p *PSCli) Read(i interface{}) error {
|
|||
func (p *PSCli) Close() error {
|
||||
if !p.closed {
|
||||
p.closed = true
|
||||
close(p.ch)
|
||||
if p.ch != nil {
|
||||
close(p.ch)
|
||||
}
|
||||
return p.con.Close()
|
||||
}
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue