diff --git a/.gitignore b/.gitignore index b2d8205..9039f61 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ config.json env/ remotegameplay room.json -laplace \ No newline at end of file +laplace +/scripts \ No newline at end of file diff --git a/config/config.go b/config/config.go index 96d6cb2..25d0703 100644 --- a/config/config.go +++ b/config/config.go @@ -23,7 +23,7 @@ type Config struct { BarrierHostName string Rooms string IPAddress string - BinaryToExecute string + ScriptToExecute string } // Exists reports whether the named file or directory exists. @@ -62,7 +62,7 @@ func SetDefaults() error { defaults["BarrierHostName"] = name defaults["Rooms"] = defaultPath + "room.json" defaults["IPAddress"] = "0.0.0.0" - defaults["BinaryToExecute"] = "/home/akilan/.local/share/Steam/steamapps/common/X-Plane 11" + defaults["ScriptToExecute"] = "" //Paths to search for config file configPaths = append(configPaths, defaultPath) diff --git a/files/main.html b/files/main.html index 7bc8ab3..d52e2d0 100644 --- a/files/main.html +++ b/files/main.html @@ -25,16 +25,16 @@
-

Start sharing your screen

-

- Click the button below to create a new streaming room, - where you can share your screen with your peers. - A RoomID will be generated, and you can share the RoomID to your peers. -

+ + + + + + - + -
+

Join streaming room

diff --git a/files/static/main.js b/files/static/main.js index d0d2054..9ccc668 100644 --- a/files/static/main.js +++ b/files/static/main.js @@ -225,8 +225,9 @@ function getServerHostName() { // Source https://stackoverflow.com/questions/247483/http-get-request-in-javascript var xmlHttp = new XMLHttpRequest() xmlHttp.open( "GET", getHttpUrl() + "/hostname", false ); // false for synchronous request - xmlHttp.send( null ); + xmlHttp.send(null); LaplaceVar.ui.barrierhostname.innerHTML = xmlHttp.responseText + //console.log(window.location.href.split('?')[0]) } function updateStatusUIStream() { @@ -252,7 +253,7 @@ function getWebsocketUrl() { function getHttpUrl() { //if (window.location.protocol === "https:") { - return `${window.location.href}` + return window.location.href.split('?')[0] // } else { // return `${window.location.href}` // } @@ -580,8 +581,17 @@ function routeByUrl() { if (paramStream && paramStream.length > 0) { return doStream(); } + // If the room ID is provided + const roomId = u.searchParams.get('roomID'); + if (roomId && roomId.length > 0) { + AddRoomID(roomId); + } } +// Adds the room information to the ID inputRoomID +function AddRoomID(roomID) { + document.getElementById('inputRoomID').value = roomID +} function leaveRoom() { window.location.href = getBaseUrl(); } diff --git a/p2prc.sh b/install.sh similarity index 66% rename from p2prc.sh rename to install.sh index 6d08d2d..8d37101 100644 --- a/p2prc.sh +++ b/install.sh @@ -7,38 +7,24 @@ # Updating and installing go compiler apt update apt install -y golang - -# Installing git +apt install -y jq +## Installing git apt install -y git - -# Installing barrier +## Installing barrier apt install -y barrier - -# Installing chromium +## Installing chromium wget https://github.com/RobRich999/Chromium_Clang/releases/download/v94.0.4585.0-r904940-linux64-deb-avx/chromium-browser-unstable_94.0.4585.0-1_amd64.deb apt install -y ./chromium-browser-unstable_94.0.4585.0-1_amd64.deb - -# clone remotegameplay distribution +# +## clone remotegameplay distribution git clone https://github.com/Akilan1999/remotegameplay -# enter cloned directory +## enter cloned directory cd remotegameplay - +# sets REMOTEGAMEPLAY path export REMOTEGAMEPLAY=$PWD # Build laplace binary file go build . -./laplace -setconfig -./laplace -tls -addr 0.0.0.0:8888 & -./laplace -headless -addr `$1` & - -sleep 2 - -./laplace -headless -roomInfo >> /tmp/output.txt - -# Installation game script here and start remote gameplay - - - - - +# Set configuration laplace file +./laplace -setconfig \ No newline at end of file diff --git a/main.go b/main.go index f83ce00..62ab6fb 100644 --- a/main.go +++ b/main.go @@ -71,7 +71,7 @@ func main() { TaskExecute = *BinaryToExcute } else { // Read binary from config file - TaskExecute = Config.BinaryToExecute + TaskExecute = Config.ScriptToExecute } // Starting screen share headless @@ -84,7 +84,11 @@ func main() { time.Sleep(3 * time.Second) // Task to be executed - RunTask(TaskExecute) + err = RunTask(TaskExecute) + if err != nil { + fmt.Println(err) + return + } return @@ -94,7 +98,7 @@ func main() { if *killServer { cmd := exec.Command("pkill" ,"laplace") if err := cmd.Run(); err != nil { - log.Fatalln(err) + fmt.Println(err) } return } @@ -102,7 +106,7 @@ func main() { if *killChromium { cmd := exec.Command("pkill" ,"chromium") if err := cmd.Run(); err != nil { - log.Fatalln(err) + fmt.Println(err) } return } @@ -151,7 +155,7 @@ func Ip4or6(s string) string { func RunTask(task string) error { // Halts the process - cmd := exec.Command(task) + cmd := exec.Command("sh",task) if err := cmd.Start(); err != nil { return err } diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..217dcec --- /dev/null +++ b/run.sh @@ -0,0 +1,28 @@ +# Starts server and runs it silently (i.e no output in the terminal) +./laplace -tls -addr 0.0.0.0:8888 > /dev/null 2>&1 & +# Starts chromium browser and runs it silently (i.e no output in the terminal) +./laplace -headless -addr ${1} > /dev/null 2>&1 & +# Lets the script sleep for 2 seconds +sleep 2 +# Gets roomInfo and stores in the tmp directory as JSON +./laplace -headless -roomInfo > /tmp/output.txt +# Gets the room ID from the JSON file and outputs to tmp directory as text +jq .id /tmp/output.txt > /tmp/test.txt +# Gets roomID from tmp directory as text +roomID=$(cat /tmp/test.txt) +# remove " from string +roomID=$(echo "$roomID" | tr -d '"') + +# Checks if the IP address is a IPV6 or IPV4 address +if [ "$1" != "${1#*[0-9].[0-9]}" ]; then + echo "https://"${1}":8888/?roomID="${roomID} +elif [ "$1" != "${1#*:[0-9a-fA-F]}" ]; then + echo "https://["${1}"]:8888/?roomID="${roomID} +else + echo "Unrecognized IP format '$1'" +fi + + + + + diff --git a/scripts/.gitkeep b/scripts/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/scripts/xplane11 b/scripts/xplane11 new file mode 100755 index 0000000..97b5622 --- /dev/null +++ b/scripts/xplane11 @@ -0,0 +1,6 @@ +# Navigating to the directory where XPlane11 is present +cd /home/akilan/.local/share/Steam/steamapps/common/X-Plane\ 11/ + +# Execute Xplane 11 binary +./X-Plane-x86_64 +