websocket: Initialize a websocket server

Description Usage Arguments Value Examples

Description

This has to be used with websocket_client.

Usage

1
2
3
websocket_server(host = "127.0.0.1", port = 8080)

websocket_client(host = "127.0.0.1", port = 8080)

Arguments

host

A string that is a valid IPv4 address that is owned by this server, or "0.0.0.0" to listen on all IP addresses.

port

A number or integer that indicates the server port that should be listened on. Note that on most Unix-like systems including Linux and Mac OS X, port numbers smaller than 1025 require root privileges.

Value

A client websocket connection

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
if (interactive()) {
 library(OSUICode)
 server <- websocket_server()
 client_1 <- websocket_client()
 client_2 <- websocket_client()
 client_1$send("Hello from client 1")
 client_2$send("Hello from client 2")
 client_1$close()
 client_2$send("Only client 2 is here")
 Sys.sleep(1)
 server$stop()
}

DivadNojnarg/outstanding-shiny-ui-code documentation built on Nov. 2, 2021, 12:03 p.m.