Skip to content

Commit

Permalink
Merge pull request #2449 from stakwork/try-fix-ws
Browse files Browse the repository at this point in the history
ws id fallbacks
  • Loading branch information
Evanfeenstra authored Jan 15, 2025
2 parents 9f1db07 + 0319b90 commit 623e610
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions websocket/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/gorilla/websocket"
"github.com/stakwork/sphinx-tribes/config"
"github.com/stakwork/sphinx-tribes/utils"
)

var WebsocketPool = NewPool()
Expand Down Expand Up @@ -35,8 +36,14 @@ func Upgrade(w http.ResponseWriter, r *http.Request) (*websocket.Conn, error) {
}

func ServeWs(pool *Pool, w http.ResponseWriter, r *http.Request) { // get url query params

// get url query params
queryParams := r.URL.Query()
uniqueId := queryParams.Get("uniqueId")
if uniqueId == "" || uniqueId == "null" || uniqueId == "undefined" {
// or random
uniqueId = utils.GetRandomToken(40)
}

conn, err := Upgrade(w, r)
if err != nil {
Expand Down

0 comments on commit 623e610

Please sign in to comment.