Add some debugging info to the client connection
This commit is contained in:
parent
4864669df6
commit
6ef0d6f1a5
|
@ -96,6 +96,7 @@ func (cr *ChatRoom) Join(name, uid string) (*Client, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
conn.clientName = name
|
||||||
client := &Client{
|
client := &Client{
|
||||||
name: name,
|
name: name,
|
||||||
conn: conn,
|
conn: conn,
|
||||||
|
|
|
@ -12,6 +12,7 @@ type chatConnection struct {
|
||||||
*websocket.Conn
|
*websocket.Conn
|
||||||
mutex sync.RWMutex
|
mutex sync.RWMutex
|
||||||
forwardedFor string
|
forwardedFor string
|
||||||
|
clientName string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *chatConnection) ReadData(data interface{}) error {
|
func (cc *chatConnection) ReadData(data interface{}) error {
|
||||||
|
@ -29,7 +30,10 @@ func (cc *chatConnection) WriteData(data interface{}) error {
|
||||||
stats.msgOutInc()
|
stats.msgOutInc()
|
||||||
err := cc.WriteJSON(data)
|
err := cc.WriteJSON(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error writing data to %s: %v", cc.Host(), err)
|
if operr, ok := err.(*net.OpError); ok {
|
||||||
|
fmt.Println("OpError: " + operr.Err.Error())
|
||||||
|
}
|
||||||
|
return fmt.Errorf("Error writing data to %s %s: %v", cc.clientName, cc.Host(), err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue