Setting up our environment

We are going to utilize the power of Node.js to build our server. If you have never programmed in Node.js before, do not worry! This technology utilizes a JavaScript engine to do all the work. This means that all of the programming will be in JavaScript so there will be no new language to learn. Now, let's perform the following steps to set up our Node.js environment:

  1. The first step to running a node.js server is to install node.js.

    Note

    You can visit the website at http://nodejs.org/ to get more information on how to install it. There are many options out there for every OS, so feel free to choose the one that best suits your needs. At the time of writing, the latest Node.js version is v0.12.4.

  2. Now you can open up your terminal application and use the node command to bring up the Node.js VM. Node.js is based on the V8 JavaScript engine that comes with Google Chrome. This means that it works extremely close to how the browser interprets JavaScript. Type in a few commands to get used to how it works:
    > 1 + 1
    2
    > var hello = "world";
    undefined
    > "Hello" + hello;
    'Helloworld'
    
  3. From here, we can start creating our server program. Luckily, Node.js runs JavaScript files as well as commands typed in the terminal. Create an index.js file with the following contents and run it using the node index.js command:
    console.log("Hello from node!");

    When you run the node index.js command, you will see the following output in the Node.js terminal:

    Hello from node!
    

This is the end of the Node.js concepts that we will cover in this book. Our implementation of a signaling server is not the most advanced, and digging into server engineering would require an entire second book's worth of content. As we move on, take time to learn more about Node.js or even translate the signaling server that we will build into your favorite language!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.69.151