New creates a new instance of API. pingPeriod: is the interval, in which is server sends the a ping to the client. pongTimeout: is the duration after the connection will be terminated, when the client does not respond with the pong command.
(pingPeriod, pongTimeout time.Duration, allowedWebSocketOrigins []string)
| 29 | // pongTimeout: is the duration after the connection will be terminated, when the client does not respond with the |
| 30 | // pong command. |
| 31 | func New(pingPeriod, pongTimeout time.Duration, allowedWebSocketOrigins []string) *API { |
| 32 | return &API{ |
| 33 | clients: make(map[uint][]*client), |
| 34 | pingPeriod: pingPeriod, |
| 35 | pongTimeout: pingPeriod + pongTimeout, |
| 36 | upgrader: newUpgrader(allowedWebSocketOrigins), |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | // CollectConnectedClientTokens returns all tokens of the connected clients. |
| 41 | func (a *API) CollectConnectedClientTokens() []string { |