diff --git a/README.md b/README.md
index 2ff85f6..f5bfe60 100644
--- a/README.md
+++ b/README.md
@@ -1,58 +1,87 @@
# Simple-app-template ~ Node-hub
-## 1. Ready (Setup)
+## **1. Ready (Setup)**
[Download Node/NPM](https://nodejs.org/en/download/) if not already installed
In a new folder, run:
-`git clone https://github.com/node-hub/AppTemplate`
-`git clone https://github.com/node-hub/dumb-client`
-
-In two terminal tabs and in this order
-1. In the AppTemplate folder =>
-* `npm install`
-* `node index.js`
+```
+git clone https://github.com/node-hub/simple-app-template
+```
-2. In the Simple-app-template folder =>
+In two terminal tabs and in this order
+1. In the AppTemplate folder =>
* `npm install`
+ - Installs all dependencies for the app to work
* `node index.js`
- - Should pull up our client
- - type command `/launch http://localhost:4444` ~ Changes socket to direct connect to your server (could be a different port if you changed the default)
-
-You should be able to see on the client a bunch of messages every second if everything is connected!
-
-## 2. Set (App logic)
-#### IMPORTANT
-Our client has some commands that we found were necessary for the client to have access to inside all apps. We suggest you include these in a '/command' or a '/help' command for your application in addition to your app commands
-* `/list` ~ Lists all the games that are currently in the app pool
-* `/launch url` ~ `url` being the address of the deployed or local app
-* `/lobby` ~ Takes you back to our chat app
-* `/exit` ~ Closes the rl interface and disconnects from the current application
-
-Also, the client only listens for 'output' and 'clear' events. Keep that in mind when formatting your logic. The output event should just print the server payload, the clear will clear the console. We won't merge any client code pull requests.
-
-#### Otherwise
-You're all set to code up your app! Pay attention to comments we've implemented as you're modifying the template!
-
-## 3. Go (Deployment)
+ - Runs our template server. We suggest using [nodemon]() while you're testing functionality of your app. Otherwise, everytime you make a change to your app, you have to rerun this command
+
+2. Run our Hubbub Community client app =>
+* `npm i -g community-hubbub`
+ - In case it's not already installed
+* `hubbub`
+ - This should pull up the client
+* Inside our client
+ * `/dev`
+ - Connects you to your server INSTANTLY
+
+***Client side***
+
+
+***Server side***
+
+
+---
+## **2. Set (App logic)**
+
+***Before you dive into any of the code, make sure to familiarize yourself with socket.io. Your server is built upon listening and emitting events to the client. The client will not work if your server doesn't work with socket.io***
+
+### IMPORTANT
+Our client has some commands that we found were necessary for the client to have access to inside all apps. We suggest you include these in your own `/command` or `/help` command for your application in addition to your own app commands
+* `/list`
+ - Lists all the games that are currently in the app pool
+* `/launch GAME`
+ - Game being one of the names from the `/list` command
+* `/lobby`
+ - Takes you back to our chat app
+* `/exit`
+ - Closes the rl interface and disconnects from the current application
+* `/dev`
+ - Changes the client to direct connect to your local server ('http://localhost:4444')
+
+Also, the client only listens for 'output' and 'clear' events that console.log the payload. Keep that in mind when emitting events server side. The output event should just print the server payload, the clear will clear the console. We won't merge any client code pull requests. If there's a feature you want implemented, document an issue and specify a pull request for our team to consider.
+
+### OTHERWISE
+You're all set to code up your app! Head on over to index.js and get shnazzy! Pay attention to comments we've implemented as you're modifying the template!
+
+---
+## **3. Go (Deployment)**
So you have your awesome application, good for you! Now in order for our chat-app to include your application in our application pool, you need to send a post request to our application as described below. Here are the steps:
-1. Get your server live on either heroku or azure
-2. Send our chat server a post request with http
- - App name ~ The name of your app
- - App URL ~ URL of your live deployment
- - Description ~ A short description of your app for the users to reference
- * example: `echo '{"name":"YOUR_APP_NAME","url":"YOUR_APP_URL","description":"APP_DESCRIPTION"}' | http post https://shrouded-everglades-62939.herokuapp.com/api/v1/app-info`
+**1.** Get your server live on either heroku or azure
+**2.** Update our /list with either option below
+Send our chat server a post request with httpie
+- **name**
+ - The name of your app
+- **url**
+ - URL of your live deployment
+- **description**
+ - A short description of your app for the users to reference
+- ***example:***
-Or optionally
-2. Send our chat server a post request with Postman
-![Postman](./assets/postman.png)
+```
+echo '{"name":"YOUR_APP_NAME","url":"YOUR_APP_URL","description":"APP_DESCRIPTION"}' | http post https://shrouded-everglades-62939.herokuapp.com/api/v1/app-info
+```
+
+Or Alternatively send our chat server a post request with Postman
+
Here is a list of our API request handlers in case you need to update or change your existing application information
+
```
-get(id) { // Gets a singular entry with the ID or all entries
- return id ? this.schema.findById(id) : this.schema.find();
+get(name) { // Gets a singular entry with the app name or all entries
+ return name ? this.schema.find({'name':name}) : this.schema.find();
}
post(obj) { //Makes a entry of your application in our list
diff --git a/assets/Client.png b/assets/Client.png
new file mode 100644
index 0000000..8aecc0a
Binary files /dev/null and b/assets/Client.png differ
diff --git a/assets/postman.png b/assets/postman.png
deleted file mode 100644
index d337858..0000000
Binary files a/assets/postman.png and /dev/null differ
diff --git a/assets/postmanv3.png b/assets/postmanv3.png
new file mode 100644
index 0000000..8cb1e6f
Binary files /dev/null and b/assets/postmanv3.png differ
diff --git a/assets/server.png b/assets/server.png
new file mode 100644
index 0000000..7b5f366
Binary files /dev/null and b/assets/server.png differ
diff --git a/index.js b/index.js
index 3440f42..06d45a8 100644
--- a/index.js
+++ b/index.js
@@ -1,23 +1,40 @@
'use strict';
-const PORT = 4444;
-
-const { phrase } = require('faker').hacker;
+// KEEP THE HARD CODED PORT TO 4444
+const PORT = process.env.PORT || 4444;
+// `io` is your server instantiated with the port
const io = require('socket.io')(PORT);
+// When sockets connect to your server
io.on('connection', socket => {
+ socket.emit('clear', '');
+ // A proof of life statement that console logs to your server terminal the socket id
console.log(`${socket.id} connected`);
-
+
+ //A welcome message for whoever joins
+ const welcome = `Hello there ${socket.id} from template server. This is a number guessing game. Guess a number between 0-9`;
+ socket.emit('output', welcome);
+
+ /*
+ The client will only emit an event('input', line), where line is what the client typed in. The client emits NO OTHER EVENTS
+ This is your app logic in this below function. Currently, this game is just a guessing game. Guess between a number between 1-10 You can build hangman with the client clear function to repaint the hung man and the letters. You can do a number guessing game. This is your job.
+ */
socket.on('input', line => {
- console.log('A line we can work with:', line);
- });
- setInterval(() => {
- const payload = phrase();
- io.emit('output', payload);
- }, 1000);
+ console.log('User Input:', line);
+
+ const num = Math.floor(Math.random()*10);
+ console.log(num)
+ if(num == line){
+ socket.emit('output', 'YOU GUESSED MY NUMBER');
+ }
+ else{
+ socket.emit('output', 'You did not guess my number');
+ }
+ });
+ //Here, upon client disconnect, your server will log which socket disconnected.
socket.on('disconnect', () => {
console.log(`${socket.id} disconnected`);
});
diff --git a/package-lock.json b/package-lock.json
index 0a7e13d..35fe678 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -162,11 +162,6 @@
"has-binary2": "~1.0.2"
}
},
- "faker": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/faker/-/faker-4.1.0.tgz",
- "integrity": "sha1-HkW7vsxndLPBlfrSg1EJxtdIzD8="
- },
"has-binary2": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz",
diff --git a/package.json b/package.json
index 9cc6663..408c1dc 100644
--- a/package.json
+++ b/package.json
@@ -19,7 +19,6 @@
},
"homepage": "https://github.com/node-hub/simple-app-template#readme",
"dependencies": {
- "faker": "^4.1.0",
"socket.io": "^2.2.0"
}
}