diff --git a/ws/message/public.go b/ws/message/public.go index fccd011..c16ffb8 100644 --- a/ws/message/public.go +++ b/ws/message/public.go @@ -23,7 +23,7 @@ func Read(socket net.Conn) (*T, error){ m.Final = bool( buffer[0] & 0x80 == 0x80 ) - m.Type = byte( buffer[0] & 0x0f ) + m.Type = Type( buffer[0] & 0x0f ) /* (3) Byte 2: Mask and Length[0] */ buffer = make([]byte, 1) @@ -103,7 +103,7 @@ func (m T) Send(socket net.Conn) error { buffer := make([]byte, 0) /* (1) Byte 0 : FIN + opcode */ - buffer = append(buffer, 0x80 | TEXT ) + buffer = append(buffer, 0x80 | byte(TEXT) ) /* (2) Get payload length */ if m.Size < 126 { // simple diff --git a/ws/message/types.go b/ws/message/types.go index 27641af..07390cd 100644 --- a/ws/message/types.go +++ b/ws/message/types.go @@ -2,18 +2,21 @@ package message // Lists websocket message types +type Type byte + const ( - TEXT = 0x1 - BINARY = 0x2 - CLOSE = 0x8 - PING = 0x9 - PONG = 0xa + CONTINUATION Type = 0x0 + TEXT Type = 0x1 + BINARY Type = 0x2 + CLOSE Type = 0x8 + PING Type = 0x9 + PONG Type = 0xa ); // Represents a websocket message type T struct { - Type byte + Type Type Data []byte Size uint Final bool