Skip to content

Commit f6ccff4

Browse files
committed
Remove wscore
1 parent 662a1b8 commit f6ccff4

File tree

7 files changed

+36
-32
lines changed

7 files changed

+36
-32
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ This package is the community standard but it is very old and over time
3333
has accumulated cruft. There are many ways to do the same thing and the API
3434
overall is just not very clear.
3535

36-
The callback hooks are also confusing. The API for this library has been designed
36+
The callback hooks . The API for this library has been designed
3737
such that there is only one way to do things and callbacks have been avoided.
3838

3939
Performance sensitive applications should use ws/wscore directly.
@@ -42,3 +42,9 @@ Performance sensitive applications should use ws/wscore directly.
4242

4343
This library has an extremely flexible API but that comes at a cost of usability
4444
and clarity. Its just not clear and simple how to do things in a safe manner.
45+
46+
## TODO
47+
48+
- [ ] Fully implement.
49+
- [ ] Decide whether we want to do WebSocket pings by default maybe every 30s?
50+
- [ ]

wscore/header.go renamed to header.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
package wscore
1+
package ws
22

33
import (
44
"io"
55
)
66

7-
// Header represents a WebSocket frame header.
7+
// header represents a WebSocket frame header.
88
// See https://tools.ietf.org/html/rfc6455#section-5.2
9-
type Header struct {
9+
// The fields are exported for easy printing for debugging.
10+
type header struct {
1011
Fin bool
1112
Rsv1 bool
1213
Rsv2 bool
1314
Rsv3 bool
14-
Opcode Opcode
15+
Opcode opcode
1516

1617
PayloadLength int64
1718

@@ -20,7 +21,7 @@ type Header struct {
2021
}
2122

2223
// Bytes returns the bytes of the header.
23-
func (h Header) Bytes() []byte {
24+
func (h header) Bytes() []byte {
2425
panic("TODO")
2526
}
2627

wscore/mask.go renamed to mask.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package wscore
1+
package ws
22

33
// Mask applies the websocket masking algorithm to p
44
// with the given key where the first 3 bits of pos
@@ -10,6 +10,6 @@ package wscore
1010
//
1111
// For targets that do not support unsafe, please report an issue.
1212
// There is a mask by byte function below that will be used for such targets.
13-
func Mask(key [4]byte, pos int, p []byte) int {
13+
func mask(key [4]byte, pos int, p []byte) int {
1414
panic("TODO")
1515
}

opcode.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package ws
2+
3+
// opcode represents a WebSocket Opcode.
4+
//go:generate stringer -type=opcode
5+
type opcode int
6+
7+
// opcode constants.
8+
const (
9+
opContinuation opcode = iota
10+
opText
11+
opBinary
12+
// 3 - 7 are reserved for further non-control frames.
13+
opClose opcode = 8 + iota
14+
opPing
15+
opPong
16+
// 11-16 are reserved for further control frames.
17+
)

wscore/opcode_string.go renamed to opcode_string.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ws.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ const (
1010
)
1111

1212
// Conn represents a WebSocket connection.
13-
type Conn struct {
14-
}
13+
type Conn struct{}
1514

1615
// Subprotocol returns the negotiated subprotocol.
1716
// An empty string means the default protocol.
@@ -47,8 +46,7 @@ func (c *Conn) Close(code StatusCode, reason string) error {
4746

4847
// MessageWriter enables writing to a WebSocket connection.
4948
// Ensure you close the MessageWriter once you have written to entire message.
50-
type MessageWriter struct {
51-
}
49+
type MessageWriter struct{}
5250

5351
// Write writes the given bytes to the WebSocket connection.
5452
// The frame will automatically be fragmented as appropriate
@@ -65,8 +63,7 @@ func (w *MessageWriter) Close() error {
6563
}
6664

6765
// MessageReader enables reading a data frame from the WebSocket connection.
68-
type MessageReader struct {
69-
}
66+
type MessageReader struct{}
7067

7168
// SetContext bounds the read operation to the ctx.
7269
// By default, the context is the one passed to conn.ReadMessage.

wscore/opcode.go

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)