-
Notifications
You must be signed in to change notification settings - Fork 5
Installation of Server and DB API Server
- To use either of the servers, you must have Nodejs installed. (https://nodejs.org/en/)
- To use the Database, you must have MongoDB installed (https://docs.mongodb.com/manual/installation/)
- We are going to need the server file and the API file. This is located at https://github.com/sqrlab/RoboGames in
./RobotON DB
,./RobotON Server
and./Bat-Term
(Just download the branch, and use that three file)
-
- The laziest way possible to get a server up and running is installing http-server (https://www.npmjs.com/package/http-server)
- To install it just issue
npm install -g http-server
command in your terminal window - To use it, go to the directory that contains all the file. In this case
RobotON Server/
- In the terminal issue the command which will start the server in port 8080
http-server ./ -p8080
-
-
The reason why this is not preferred is that this server was set up to listen to any incoming changes from Github. If there were any changes, it would start the auto compiler. However, the server would get knocked offline, since it wouldn't know how to handle some request
-
if you are planning to use this server to auto compile, then there are two options.
-
-
To receive mail on when the compile started and ended you first must make a JSON file called
config.json
located outside of theRobotON Server
directory -
The content of the file inside look like this (Yes storing password openly):
{ "email": "EMAIL FOR SENDING TO EMAIL2", "password" : "EMAIL PASSWORD", "email2" : "EMAIL FOR RECEIVING EMAIL" }
-
Setup the Github webhook in your Github Project setting
-
Depending on what system you are using, we will need to configure the script accordingly
- In
RobotON Server/
there is either a file calledCompileProject.sh
(Linux) orrun.bat
(Window)- In
run.bat
orCompileProject.sh
you are going to have to set the path to where your Unity installation is installed, and on the same line, where-projectPath
is located, set the path to where the project is being held at - The first cd command in the
run.bat
, should have the appropriate path on where the server is located, the second should be the appropriate path to where theBat-Term Script
is being held
- In
- In
server.js
line 64child.spawn("./CompileProject.sh");
change theCompileProject.sh
torun.bat
if you are using Windows
- In
-
In the directory of
RobotON Server
, opening the terminal, and type innpm start
-
You should be good, if there is any trouble, it could just be a path problem
-
-
-
Setup the Github webhook in your Github Project setting
-
Depending on what system you are using, we will need to configure the script accordingly
- In
RobotON Server/
there is either a file calledCompileProject.sh
(Linux) orrun.bat
(Window)- In
run.bat
orCompileProject.sh
you are going to have to set the path to where your Unity installation is installed, and on the same line, where-projectPath
is located, set the path to where the project is being held at - The first cd command in the
run.bat
, should have the appropriate path on where the server is located, the second should be the appropriate path to where theBat-Term Script
is being held
- In
- In
server.js
line 64child.spawn("./CompileProject.sh");
change theCompileProject.sh
torun.bat
if you are using Windows
- In
-
In
server.js
comment out this codevar transporter = nodemailer.createTransport({ service: 'gmail', auth: { user: config.email, pass: config.password } });
and this code
if(jsonString.commits.length != 0){ console.log("Git Push Request"); var dateTime = new Date(); //The code below should be commented out sendEmail("Unity Compilation Notice!", "Started Compiling at " + dateTime );
-
In the directory of
RobotON Server
, opening the terminal, and type innpm start
-
-
-
-
- To use the DB such that the game can be communicated with server, we are going to use the
./RobotON DB
Directory
- In the terminal, type
mongod
, this will start the DB server. If the commandmongod
is not found, you may have to set the appropriate path. If it does launches but quickly closes, then you may have to set the/data/db
directory in your system. Make sure to type 'mongod' in the drive that the '/data/db' directory is located in. - In another Terminal, navigate to the location of './RobotON DB' Directory and type
npm start
- You are done! :)
- To use the DB such that the game can be communicated with server, we are going to use the
The model on which the DB store data is :
var roboSchema = new Schema({
name: {
type: String,
unique: true,
required: 'Please Enter your name!'
},
username: String,
timeStarted: String,
totalPoints: String,
currentPoints: String,
speedUpgrades: String,
xpUpgrades: String,
resistanceUpgrade: String,
energyUpgrades: String,
upgrades: [{
name: String,
timestamp: String,
prePoints: String,
curPoints: String,
}],
levels:[{
name: String,
time: String,
progress: String,
timeStarted: String,
timeEnded: String,
stars: String,
points: String,
totalPoint: String,
timeBonus: String,
finalEnergy: String,
AdaptiveCategorization: String,
AdaptiveMode: String,
HintMode: String,
failures: String,
hitByEnemy: String,
failedToolUse: String,
bugLine: Number,
idleTime: Number,
events : [{
eventName: String,
eventType: String,
line: Number,
success: Boolean,
elapsedTime: String,
realTime: String,
preEnergy: String,
finEnergy: String,
position: {
x_pos: String,
y_pos: String,
},
comment: String,
}],
}]
})
var courseSchema = new mongoose.Schema({
courseCode:{
type: String,
unique: true,
required: 'Please Enter your course code!'
},
students: [roboSchema],
})
Work in progress so these may change:
URL endpoint | Method | What it does |
---|---|---|
/logsON | GET,POST | GET: Returns all Data in DB POST: Used for putting Initial Data to DB |
/logsON/:sessionID | GET,PUT | GET: Returns Data that is tied to that SessionID PUT: Put Initial Level Data to DB |
/logsON/completedlevels/:sessionID | GET | GET: Returns all completed level that is tied to the sessionID, plus the level the user was on |
/logsON/currentlevel/:sessionID/:name | PUT | PUT: Put Data to the current level that the sessionID is tied to name is there to Put certain data |
/logsON/points/:sessionID/:name | GET,PUT | GET: Returns points that are tied to the sessionID PUT: Puts points that are tied to the sessionID name is there to Get/Put certain points |
/logsON/check/:word | GET | GET: Returns true if the username exists, or if the username has explicit word else it would return false (NOT IN USE) |
/logsON/leaderboard/:levelName | GET | GET: Returns all user with points, and the ranking (NOT IN USE) |
URL endpoint | Method | What it does |
---|---|---|
/logsBUG | GET,POST | GET: Returns all Data in DB POST: Used for putting Initial Data to DB |
/logsBUG/:sessionID | GET,PUT | GET: Returns Data that is tied to that SessionID PUT: Put Initial Level Data to DB |
/logsBUG/completedlevels/:sessionID | GET | GET: Returns all completed level that is tied to the sessionID, plus the level the user was on |
/logsBUG/currentlevel/:sessionID/:name | PUT | PUT: Put Data to the current level that the sessionID is tied to name is there to Put certain data |
/logsBUG/points/:sessionID/:name | GET,PUT | GET: Returns points that are tied to the sessionID PUT: Puts points that are tied to the sessionID name is there to Get/Put certain points |
/logsON/check/:word | GET | GET: Returns true if the username exist, or if the username has explicit word else it would return false (NOT IN USE) |
/logsON/leaderboard/:levelName | GET | GET: Returns all user with points, and the ranking (NOT IN USE) |
Well Assuming you have the game compiled for web, and you know the directory, There are two options
- Put the game folder, where the Game File server is located, and all you have to do is enter in the browser
<URL>:<Port>\(BuildFolderName)
- Using the lazy way in Installing the Server, Go into the build file, and launch
http-server
from there
In terms of compiling the game for the web, make sure to have WebGL support for unity in the build settings make sure to build with WebGL. Make sure that Title Screen is the first scene in the build.
You will want to build the game inside the './RobotON Server' Directory, that way you have the correct assets and to simplify launching the server. After you are done building navigate to './RobotON Server' and launch 'http-server' from there.
Assuming you have port forwarded some other ports than the one I used, it is really simple,
- For the
http-server
, just set the-p
argument with the port number you like - For
./RobotON Server
, just set the port number inserver.js
to whatever you like, the same thing with./RobotON DB
- I would suggest leaving mongo port not forwarded, and kept the same
We have a separate branch at https://github.com/Mvtj22/ServerDockerFileSQR that has the file structure and dockerfile you need to make the docker image.
You'll want to make 2 separate Docker images. One for the RobotON DB and then another for RobotON Server.
- For the RobotON DB just go into the folder and then create the docker image there.
- For the RobotON Server you will see the index.html that is a simple webpage to redirect to the different game modes, change the links to redirect where the server is. Then but your build of each game in their respective folders and create the Docker Image once in the RobotON Server Folder.