@@ -251,13 +251,13 @@ func genServerConnID(s *Server, c *Conn) string {
251
251
}
252
252
253
253
// 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
255
255
// and it does return the connection or any errors.
256
256
func (s * Server ) Upgrade (
257
257
w http.ResponseWriter ,
258
258
r * http.Request ,
259
259
socketWrapper func (Socket ) Socket ,
260
- customID string ,
260
+ customIDGen IDGenerator ,
261
261
) (* Conn , error ) {
262
262
if atomic .LoadUint32 (& s .closed ) > 0 {
263
263
http .Error (w , http .StatusText (http .StatusInternalServerError ), http .StatusInternalServerError )
@@ -296,8 +296,8 @@ func (s *Server) Upgrade(
296
296
}
297
297
298
298
c := newConn (socket , s .namespaces )
299
- if customID != "" {
300
- c .id = customID
299
+ if customIDGen != nil {
300
+ c .id = customIDGen ( w , r )
301
301
} else {
302
302
c .id = s .IDGenerator (w , r )
303
303
}
@@ -372,7 +372,7 @@ func (s *Server) Upgrade(
372
372
// ServeHTTP completes the `http.Handler` interface, it should be passed on a http server's router
373
373
// to serve this neffos server on a specific endpoint.
374
374
func (s * Server ) ServeHTTP (w http.ResponseWriter , r * http.Request ) {
375
- s .Upgrade (w , r , nil , "" )
375
+ s .Upgrade (w , r , nil , nil )
376
376
}
377
377
378
378
func (s * Server ) waitMessage (c * Conn ) bool {
0 commit comments