Skip to content

Commit 9b3aafa

Browse files
committed
1 parent c6806f1 commit 9b3aafa

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

server.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,13 @@ func genServerConnID(s *Server, c *Conn) string {
251251
}
252252

253253
// Upgrade handles the connection, same as `ServeHTTP` but it can accept
254-
// a socket wrapper and a "customID" that overrides the server's IDGenerator
254+
// a socket wrapper and a "customIDGen" that overrides the server's IDGenerator
255255
// and it does return the connection or any errors.
256256
func (s *Server) Upgrade(
257257
w http.ResponseWriter,
258258
r *http.Request,
259259
socketWrapper func(Socket) Socket,
260-
customID string,
260+
customIDGen IDGenerator,
261261
) (*Conn, error) {
262262
if atomic.LoadUint32(&s.closed) > 0 {
263263
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
@@ -296,8 +296,8 @@ func (s *Server) Upgrade(
296296
}
297297

298298
c := newConn(socket, s.namespaces)
299-
if customID != "" {
300-
c.id = customID
299+
if customIDGen != nil {
300+
c.id = customIDGen(w, r)
301301
} else {
302302
c.id = s.IDGenerator(w, r)
303303
}
@@ -372,7 +372,7 @@ func (s *Server) Upgrade(
372372
// ServeHTTP completes the `http.Handler` interface, it should be passed on a http server's router
373373
// to serve this neffos server on a specific endpoint.
374374
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
375-
s.Upgrade(w, r, nil, "")
375+
s.Upgrade(w, r, nil, nil)
376376
}
377377

378378
func (s *Server) waitMessage(c *Conn) bool {

0 commit comments

Comments
 (0)