Skip to content

Commit

Permalink
More comments in code
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Jan 12, 2024
1 parent fdb6d17 commit 366930e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions httpx/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,25 @@ const (

var upgrader = websocket.Upgrader{ReadBufferSize: 1024, WriteBufferSize: 1024}

// WebSocket provides a websocket interface similar to that of Javascript.
type WebSocket interface {
// Start begins reading and writing of messages on this socket
Start()

// Send sends the given message over the socket
Send([]byte)

// Close closes the socket connection
Close(int)

OnMessage(fn func([]byte))
OnClose(fn func(int))
// OnMessage is called when the socket receives a message
OnMessage(func([]byte))

// OnClose is called when the socket is closed (even if we initiate the close)
OnClose(func(int))
}

// Socket implemention using gorilla library
// WebSocket implemention using gorilla library
type socket struct {
conn *websocket.Conn
onMessage func([]byte)
Expand Down

0 comments on commit 366930e

Please sign in to comment.