diff --git a/ws/frame/opcode/types.go b/ws/frame/opcode/types.go deleted file mode 100644 index e39199f..0000000 --- a/ws/frame/opcode/types.go +++ /dev/null @@ -1,34 +0,0 @@ -package opcode - -import ( - "git.xdrm.io/gws/ws/frame" -) - -// Represents OpCode Values -const ( - // frame continuation - CONTINUATION frame.OpCode = 0x00 - - // frame type - TEXT frame.OpCode = 0x01 - BINARY frame.OpCode = 0x02 - - // reserved for non-control frames - RSV1 frame.OpCode = 0x03 - RSV2 frame.OpCode = 0x04 - RSV3 frame.OpCode = 0x05 - RSV4 frame.OpCode = 0x06 - - // connection close - CLOSE frame.OpCode = 0x08 - - // ping pong - PING frame.OpCode = 0x09 - PONG frame.OpCode = 0x0A - - // reserved for control frames - CRSV1 frame.OpCode = 0x0B - CRSV2 frame.OpCode = 0x0C - CRSV3 frame.OpCode = 0x0D - CRSV4 frame.OpCode = 0x0E -) \ No newline at end of file diff --git a/ws/frame/types.go b/ws/frame/types.go deleted file mode 100644 index 949d3b6..0000000 --- a/ws/frame/types.go +++ /dev/null @@ -1,25 +0,0 @@ -package frame - -import ( - "fmt" -) - -// Represenst Frame errors -var ErrMalFormed = fmt.Errorf("Malformed Frame") - - -// Represents an OpCode -type OpCode byte - -// Represents a frame header -type Header struct { - Fin bool - Opc OpCode - Msk []byte // len() = 4 if set, else nil -} - -// Represents a frame message -type Payload struct { - Buffer []byte - Length uint64 -} \ No newline at end of file diff --git a/ws/spec/const.go b/ws/spec/const.go deleted file mode 100644 index b190920..0000000 --- a/ws/spec/const.go +++ /dev/null @@ -1,5 +0,0 @@ -package spec - -const maxBufferLength = 4096 -const maxHeaderLength = 2 + 8 + 4 -const maxChannelBufferLength = 1 diff --git a/ws/types.go b/ws/types.go deleted file mode 100644 index ebb4bd6..0000000 --- a/ws/types.go +++ /dev/null @@ -1,63 +0,0 @@ -package ws - -import ( - "sync" - "bufio" - "net" - "git.xdrm.io/gws/internal/uri/parser" - "git.xdrm.io/gws/ws/frame" -) - -const maxBufferLength = 4096 -const maxHeaderLength = 2 + 8 + 4 -const maxChannelBufferLength = 1 - -// Represents a websocket connection (socket + reader) -type Conn struct { - sock net.Conn - br *bufio.Reader -} - -// Represents a websocket controller callback function -type ControllerFunc func(*Client, <-chan Frame, chan<- []byte, <-chan func()) - -// Represents a websocket controller -type Controller struct { - uri *parser.Scheme // uri scheme - fun ControllerFunc // controller function -} - - -// Represents a websocket client -type Client struct { - conn Conn // connection (socket + reader) - Protocol string // choosen protocol (Sec-WebSocket-Protocol) - Arguments [][]string // URI parameters, index 0 is full URI, then matching groups - - Controller *Controller // assigned controller - Store struct{} // store (for client implementation-specific data) - - recvc chan Frame // Receive channel - sendc chan []byte // sending channel - closec chan func() // closing channel -} - -// Represents a websocket srever -type Server struct { - sock net.Listener // listen socket - addr []byte // server listening ip/host - port uint16 // server listening port - - clients map[net.Conn]*Client // clients - clientsMutex sync.Mutex - - defaultController *Controller // default controller - controllers []*Controller // URI-bound controllers -} - - -// Represents a websocket frame -type Frame struct { - Header frame.Header - Payload frame.Payload -} \ No newline at end of file