good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit f6ccff4d authored by Anmol Sethi's avatar Anmol Sethi
Browse files

Remove wscore

parent 662a1b89
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@ This package is the community standard but it is very old and over time
has accumulated cruft. There are many ways to do the same thing and the API
overall is just not very clear.
The callback hooks are also confusing. The API for this library has been designed
The callback hooks . The API for this library has been designed
such that there is only one way to do things and callbacks have been avoided.
Performance sensitive applications should use ws/wscore directly.
......@@ -42,3 +42,9 @@ Performance sensitive applications should use ws/wscore directly.
This library has an extremely flexible API but that comes at a cost of usability
and clarity. Its just not clear and simple how to do things in a safe manner.
## TODO
- [ ] Fully implement.
- [ ] Decide whether we want to do WebSocket pings by default maybe every 30s?
- [ ]
package wscore
package ws
import (
"io"
)
// Header represents a WebSocket frame header.
// header represents a WebSocket frame header.
// See https://tools.ietf.org/html/rfc6455#section-5.2
type Header struct {
// The fields are exported for easy printing for debugging.
type header struct {
Fin bool
Rsv1 bool
Rsv2 bool
Rsv3 bool
Opcode Opcode
Opcode opcode
PayloadLength int64
......@@ -20,7 +21,7 @@ type Header struct {
}
// Bytes returns the bytes of the header.
func (h Header) Bytes() []byte {
func (h header) Bytes() []byte {
panic("TODO")
}
......
package wscore
package ws
// Mask applies the websocket masking algorithm to p
// with the given key where the first 3 bits of pos
......@@ -10,6 +10,6 @@ package wscore
//
// For targets that do not support unsafe, please report an issue.
// There is a mask by byte function below that will be used for such targets.
func Mask(key [4]byte, pos int, p []byte) int {
func mask(key [4]byte, pos int, p []byte) int {
panic("TODO")
}
package wscore
package ws
// Opcode represents a WebSocket Opcode.
//go:generate stringer -type=Opcode
type Opcode int
// opcode represents a WebSocket Opcode.
//go:generate stringer -type=opcode
type opcode int
// Opcode constants.
// opcode constants.
const (
OpContinuation Opcode = iota
OpText
OpBinary
opContinuation opcode = iota
opText
opBinary
// 3 - 7 are reserved for further non-control frames.
OpClose Opcode = 8 + iota
OpPing
OpPong
opClose opcode = 8 + iota
opPing
opPong
// 11-16 are reserved for further control frames.
)
// Code generated by "stringer -type=Opcode"; DO NOT EDIT.
package wscore
package ws
import "strconv"
......
......@@ -10,8 +10,7 @@ const (
)
// Conn represents a WebSocket connection.
type Conn struct {
}
type Conn struct{}
// Subprotocol returns the negotiated subprotocol.
// An empty string means the default protocol.
......@@ -47,8 +46,7 @@ func (c *Conn) Close(code StatusCode, reason string) error {
// MessageWriter enables writing to a WebSocket connection.
// Ensure you close the MessageWriter once you have written to entire message.
type MessageWriter struct {
}
type MessageWriter struct{}
// Write writes the given bytes to the WebSocket connection.
// The frame will automatically be fragmented as appropriate
......@@ -65,8 +63,7 @@ func (w *MessageWriter) Close() error {
}
// MessageReader enables reading a data frame from the WebSocket connection.
type MessageReader struct {
}
type MessageReader struct{}
// SetContext bounds the read operation to the ctx.
// By default, the context is the one passed to conn.ReadMessage.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment