func (s *Socket) readMessage() (*message.Message, error) {
	var m message.Message
	if err := s.Conn.ReadMessage(&m); err != nil { // BLOCKING
		if !s.Conn.IsNormalClose(err) {
			return nil, fmt.Errorf("unexpected socket closure: %v", err)
		}
		return nil, errSocketClosed
	}
	if s.Debug {
		s.log.Printf("socket reading message with type %v", m.Type)
	}
	if m.Game == nil {
		return nil, fmt.Errorf("received message not relating to game")
	}
	// Add the player name and address so subscribers of the socket can know who to send responses to because the out channel is shared.
	m.PlayerName = s.PlayerName
	m.Addr = s.Addr
	return &m, nil
}
// readMessage reads the next message from the connection.
readMessage reads the next message from the connection.
// readMessage reads the next message from the connection .
func (s *Socket) readMessage() (*message.Message, error) {
	var m message.Message
	if err := s.Conn.ReadMessage(&m); err != nil { 
		if !s.Conn.IsNormalClose(err) {
			return nil, fmt.Errorf("unexpected socket closure: %v", err)
		}
		return nil, errSocketClosed
	}
	if s.Debug {
		s.log.Printf("socket reading message with type %v", m.Type)
	}
	if m.Game == nil {
		return nil, fmt.Errorf("received message not relating to game")
	}
	m.PlayerName = s.PlayerName
	m.Addr = s.Addr
	return &m, nil
}
func ( s * Socket ) readMessage ( ) ( * message . Message , error ) { var m message . Message if err := s . Conn . ReadMessage ( & m ) ; err != nil { if ! s . Conn . IsNormalClose ( err ) { return nil , fmt . Errorf ( " " , err ) } return nil , errSocketClosed } if s . Debug { s . log . Printf ( " " , m . Type ) } if m . Game == nil { return nil , fmt . Errorf ( " " ) } m . PlayerName = s . PlayerName m . Addr = s . Addr return & m , nil }
readMessage reads the next message from the connection.
readMessage reads the next message from the connection .
// BLOCKING // Add the player name and address so subscribers of the socket can know who to send responses to because the out channel is shared.