I'll operate rshiny app in win10 as server
Running Rshiny in a win10 environment and running the server with the code shown in the example below,
I want to receive and store the information of the client connecting with the assigned host ip.
what should I do if I want to get the username of another win10 client or client's Computername?
The Sys.getenv() function like the code below only returns the server's username...
shinydashboard_test.R
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title="Test"),
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", tabName = "widgets", icon = icon("th"))
)
),
dashboardBody(
tabItems(
tabItem(tabName="dashboard",
fluidRow(
box(plotOutput("plot1",height=250)),
box(
title="Contorls",
sliderInput("slider","Number of ovservations",1,100,50)
)
)
),
tabItem(tabName="widgets",
h2("Widgets tab Content")
)
)
)
)
server <- function(input,output,session){
set.seed(122)
histdata <- rnorm(500)
ip <- session$request$REMOTE_ADDR
cat("ip:",ip,"time : ",as.character(Sys.time()),"user :", as.character(Sys.getenv("USERNAME")),"\n")
output$plot1 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
}
shinyApp(ui,server)
runShiny.R
require(shiny)
folder_address="C:/shinydashboard_test.R"
x <- system("ipconfig",intern=TRUE)
z <- x[grep("IPv4",x)]
ip <- gsub(".*?([[:digit:]])","\\1",z)
print(paste0("the Shiny Web application runs on: http://",ip,":8080/"))
runApp(folder_address,launch.browser = TRUE,port=8080,host=ip)