added bash script to automatically start gameplay
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,4 +2,5 @@ config.json
|
||||
env/
|
||||
remotegameplay
|
||||
room.json
|
||||
laplace
|
||||
laplace
|
||||
/scripts
|
||||
@@ -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)
|
||||
|
||||
@@ -25,16 +25,16 @@
|
||||
|
||||
<div class="separator"></div>
|
||||
|
||||
<h4>Start sharing your screen</h4>
|
||||
<p class="help-text">
|
||||
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.
|
||||
</p>
|
||||
<!-- <h4>Start sharing your screen</h4>-->
|
||||
<!-- <p class="help-text">-->
|
||||
<!-- 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.-->
|
||||
<!-- </p>-->
|
||||
|
||||
<button type="button" class="btn btn-dark btn-block" id="btnStream">Start sharing</button>
|
||||
<!-- <button type="button" class="btn btn-dark btn-block" id="btnStream">Start sharing</button>-->
|
||||
|
||||
<div class="separator"></div>
|
||||
<!-- <div class="separator"></div>-->
|
||||
|
||||
<h4>Join streaming room</h4>
|
||||
<p class="help-text">
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
14
main.go
14
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
|
||||
}
|
||||
|
||||
28
run.sh
Normal file
28
run.sh
Normal file
@@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
0
scripts/.gitkeep
Normal file
0
scripts/.gitkeep
Normal file
6
scripts/xplane11
Executable file
6
scripts/xplane11
Executable file
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user