startWS initializes and starts the websocket RPC endpoint.
(endpoint string, apis []rpc.API, modules []string, wsOrigins []string, exposeAll bool)
| 360 | |
| 361 | // startWS initializes and starts the websocket RPC endpoint. |
| 362 | func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsOrigins []string, exposeAll bool) error { |
| 363 | // Short circuit if the WS endpoint isn't being exposed |
| 364 | if endpoint == "" { |
| 365 | return nil |
| 366 | } |
| 367 | listener, handler, err := rpc.StartWSEndpoint(endpoint, apis, modules, wsOrigins, exposeAll) |
| 368 | if err != nil { |
| 369 | return err |
| 370 | } |
| 371 | n.log.Info("WebSocket endpoint opened", "url", fmt.Sprintf("ws://%s", listener.Addr())) |
| 372 | // All listeners booted successfully |
| 373 | n.wsEndpoint = endpoint |
| 374 | n.wsListener = listener |
| 375 | n.wsHandler = handler |
| 376 | |
| 377 | return nil |
| 378 | } |
| 379 | |
| 380 | // stopWS terminates the websocket RPC endpoint. |
| 381 | func (n *Node) stopWS() { |