Skip to content

Commit

Permalink
handler function is spawn after receiver is attached
Browse files Browse the repository at this point in the history
  • Loading branch information
igm committed Nov 15, 2019
1 parent 1a1bca4 commit a5a553e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,6 +7,7 @@
# Folders
_obj
_test
.idea

# Architecture specific extensions/prefixes
*.[568vq]
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -2,8 +2,8 @@ sudo: false
language: go

go:
- "1.10.x"
- "1.9.x"
- "1.13.x"
- "1.12.x"
- tip

notifications:
Expand Down
6 changes: 3 additions & 3 deletions sockjs/rawwebsocket.go
Expand Up @@ -29,12 +29,12 @@ func (h *handler) rawWebsocket(rw http.ResponseWriter, req *http.Request) {
sessID := ""
sess := newSession(req, sessID, h.options.DisconnectDelay, h.options.HeartbeatDelay)
sess.raw = true
if h.handlerFunc != nil {
go h.handlerFunc(sess)
}

receiver := newRawWsReceiver(conn, h.options.WebsocketWriteTimeout)
sess.attachReceiver(receiver)
if h.handlerFunc != nil {
go h.handlerFunc(sess)
}
readCloseCh := make(chan struct{})
go func() {
for {
Expand Down
5 changes: 2 additions & 3 deletions sockjs/websocket.go
Expand Up @@ -35,12 +35,11 @@ func (h *handler) sockjsWebsocket(rw http.ResponseWriter, req *http.Request) {
}
sessID, _ := h.parseSessionID(req.URL)
sess := newSession(req, sessID, h.options.DisconnectDelay, h.options.HeartbeatDelay)
receiver := newWsReceiver(conn, h.options.WebsocketWriteTimeout)
sess.attachReceiver(receiver)
if h.handlerFunc != nil {
go h.handlerFunc(sess)
}

receiver := newWsReceiver(conn, h.options.WebsocketWriteTimeout)
sess.attachReceiver(receiver)
readCloseCh := make(chan struct{})
go func() {
var d []string
Expand Down

0 comments on commit a5a553e

Please sign in to comment.