removed unused
This commit is contained in:
parent
09b3cc8921
commit
378534153c
|
@ -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
|
||||
)
|
|
@ -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
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
package spec
|
||||
|
||||
const maxBufferLength = 4096
|
||||
const maxHeaderLength = 2 + 8 + 4
|
||||
const maxChannelBufferLength = 1
|
63
ws/types.go
63
ws/types.go
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue