Handle handles incoming requests. First it upgrades the protocol to the WebSocket protocol and then starts listening for read and writes. swagger:operation GET /stream message streamMessages Websocket, return newly created messages. --- schema: ws, wss produces: [application/json] security: [c
(ctx *gin.Context)
| 141 | // schema: |
| 142 | // $ref: "#/definitions/Error" |
| 143 | func (a *API) Handle(ctx *gin.Context) { |
| 144 | conn, err := a.upgrader.Upgrade(ctx.Writer, ctx.Request, nil) |
| 145 | if err != nil { |
| 146 | ctx.Error(err) |
| 147 | return |
| 148 | } |
| 149 | |
| 150 | client := newClient(conn, auth.GetUserID(ctx), auth.GetTokenID(ctx), a.remove) |
| 151 | a.register(client) |
| 152 | go client.startReading(a.pongTimeout) |
| 153 | go client.startWriteHandler(a.pingPeriod) |
| 154 | } |
| 155 | |
| 156 | // Close closes all client connections and stops answering new connections. |
| 157 | func (a *API) Close() { |
nothing calls this directly
no test coverage detected