Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>1. Steps</strong></p> <p>1.1) <code>Run</code> server.js</p> <p><img src="https://i.stack.imgur.com/ttyrB.png" alt="enter image description here"></p> <p>The cloud 9 console shows up:</p> <p><img src="https://i.stack.imgur.com/vBVch.png" alt="enter image description here"></p> <p>1.2) Hit <code>Preview</code> on index.html</p> <p><img src="https://i.stack.imgur.com/Vl4tF.png" alt="enter image description here"></p> <p>1.3) Then a window is opening on the right side of your IDE. You can either hit the button in the middle of the navigation bar or copy and paste the url into a new browser window.</p> <p><img src="https://i.stack.imgur.com/ZtlFo.png" alt="enter image description here"></p> <p>1.4) Socket communication is working!</p> <p><img src="https://i.stack.imgur.com/Fx1qs.png" alt="enter image description here"></p> <p><img src="https://i.stack.imgur.com/raHrg.png" alt="enter image description here"></p> <p><br><br></p> <p><strong>2. Prerequisite</strong></p> <p>2.1) node module socket.io</p> <p>Hit <code>F6</code> or <code>View -&gt; Console</code> and install socket.io.</p> <p><img src="https://i.stack.imgur.com/orSc8.png" alt="enter image description here"></p> <p>2.2) the client side JavaScript from socket.io</p> <p>Since I didn't find an official link to download it, I created a GitHubGist.</p> <p><a href="https://gist.github.com/MatthiasHoldorf/7957556" rel="noreferrer">socket.io.js</a></p> <p><br><br></p> <p><strong>3. Code</strong></p> <p><strong>server.js</strong></p> <pre><code>// module dependencies var http = require("http"), sio = require("socket.io"); // create http server var server = http.createServer().listen(process.env.PORT, process.env.IP), // create socket server io = sio.listen(server); // set socket.io debugging io.set('log level', 1); io.sockets.on('connection', function (socket) { socket.emit('news', { message: 'Hello world!' }); socket.on('my other event', function (data) { console.log(data.message); }); }); </code></pre> <p><br> <strong>index.html</strong></p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;script src="js/socket.io.js"&gt;&lt;/script&gt; &lt;script&gt; var socket = io.connect("https://demo-project-c9-matthiasholdorf.c9.io"); socket.on("news", function(data) { console.log(data.message); }); socket.emit("my other event", { message : "client emit" } ); &lt;/script&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload