good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
websocket
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
websocket
Commits
f6ccff4d
Unverified
Commit
f6ccff4d
authored
5 years ago
by
Anmol Sethi
Browse files
Options
Downloads
Patches
Plain Diff
Remove wscore
parent
662a1b89
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
README.md
+7
-1
7 additions, 1 deletion
README.md
header.go
+6
-5
6 additions, 5 deletions
header.go
mask.go
+2
-2
2 additions, 2 deletions
mask.go
opcode.go
+17
-0
17 additions, 0 deletions
opcode.go
opcode_string.go
+1
-1
1 addition, 1 deletion
opcode_string.go
ws.go
+3
-6
3 additions, 6 deletions
ws.go
with
36 additions
and
15 deletions
README.md
+
7
−
1
View file @
f6ccff4d
...
...
@@ -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?
-
[ ]
This diff is collapsed.
Click to expand it.
wscore/
header.go
→
header.go
+
6
−
5
View file @
f6ccff4d
package
ws
core
package
ws
import
(
"io"
)
//
H
eader represents a WebSocket frame header.
//
h
eader 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
O
pcode
Opcode
o
pcode
PayloadLength
int64
...
...
@@ -20,7 +21,7 @@ type Header struct {
}
// Bytes returns the bytes of the header.
func
(
h
H
eader
)
Bytes
()
[]
byte
{
func
(
h
h
eader
)
Bytes
()
[]
byte
{
panic
(
"TODO"
)
}
...
...
This diff is collapsed.
Click to expand it.
wscore/
mask.go
→
mask.go
+
2
−
2
View file @
f6ccff4d
package
ws
core
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
M
ask
(
key
[
4
]
byte
,
pos
int
,
p
[]
byte
)
int
{
func
m
ask
(
key
[
4
]
byte
,
pos
int
,
p
[]
byte
)
int
{
panic
(
"TODO"
)
}
This diff is collapsed.
Click to expand it.
wscore/
opcode.go
→
opcode.go
+
17
−
0
View file @
f6ccff4d
package
ws
core
package
ws
//
O
pcode represents a WebSocket Opcode.
//go:generate stringer -type=
O
pcode
type
O
pcode
int
//
o
pcode represents a WebSocket Opcode.
//go:generate stringer -type=
o
pcode
type
o
pcode
int
//
O
pcode constants.
//
o
pcode constants.
const
(
O
pContinuation
O
pcode
=
iota
O
pText
O
pBinary
o
pContinuation
o
pcode
=
iota
o
pText
o
pBinary
// 3 - 7 are reserved for further non-control frames.
O
pClose
O
pcode
=
8
+
iota
O
pPing
O
pPong
o
pClose
o
pcode
=
8
+
iota
o
pPing
o
pPong
// 11-16 are reserved for further control frames.
)
This diff is collapsed.
Click to expand it.
wscore/
opcode_string.go
→
opcode_string.go
+
1
−
1
View file @
f6ccff4d
// Code generated by "stringer -type=Opcode"; DO NOT EDIT.
package
ws
core
package
ws
import
"strconv"
...
...
This diff is collapsed.
Click to expand it.
ws.go
+
3
−
6
View file @
f6ccff4d
...
...
@@ -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.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment