Upgrade upgrades the request and returns a new websocket Conn. Use `Handler` for higher-level implementation instead.
(ctx *context.Context, idGen IDGenerator, s *neffos.Server)
| 185 | // Upgrade upgrades the request and returns a new websocket Conn. |
| 186 | // Use `Handler` for higher-level implementation instead. |
| 187 | func Upgrade(ctx *context.Context, idGen IDGenerator, s *neffos.Server) *neffos.Conn { |
| 188 | /* Do NOT return the error as it is captured on the OnUpgradeError listener, |
| 189 | the end-developer should not be able to write to this http client directly. */ |
| 190 | ctx.DisablePoolRelease() |
| 191 | |
| 192 | conn, upgradeErr := s.Upgrade(ctx.ResponseWriter(), ctx.Request(), func(socket neffos.Socket) neffos.Socket { |
| 193 | return &socketWrapper{ |
| 194 | Socket: socket, |
| 195 | ctx: ctx, |
| 196 | } |
| 197 | }, wrapIDGenerator(idGen)(ctx)) |
| 198 | |
| 199 | if upgradeErr != nil { |
| 200 | manualReleaseWithoutResp(ctx) |
| 201 | } |
| 202 | |
| 203 | return conn |
| 204 | } |
| 205 | |
| 206 | func manualReleaseWithoutResp(ctx *context.Context) { |
| 207 | ctx.ResponseWriter().EndResponse() // relases the response writer (common, recorder & compress). |
no test coverage detected
searching dependent graphs…