Add some debugging info to the client connection

This commit is contained in:
Zorchenhimer 2019-03-23 16:09:47 -04:00
parent 4864669df6
commit 6ef0d6f1a5
2 changed files with 6 additions and 1 deletions

View File

@ -96,6 +96,7 @@ func (cr *ChatRoom) Join(name, uid string) (*Client, error) {
}
}
conn.clientName = name
client := &Client{
name: name,
conn: conn,

View File

@ -12,6 +12,7 @@ type chatConnection struct {
*websocket.Conn
mutex sync.RWMutex
forwardedFor string
clientName string
}
func (cc *chatConnection) ReadData(data interface{}) error {
@ -29,7 +30,10 @@ func (cc *chatConnection) WriteData(data interface{}) error {
stats.msgOutInc()
err := cc.WriteJSON(data)
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
}