03.12.2015 Views

laravel4cookbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Embedded Systems 290<br />

14 Laravel 4 Embedded Systems<br />

15 <br />

16 <br />

17 <br />

18 <br />

19 <br />

20 <br />

21 <br />

22 <br />

23 <br />

24 <br />

25 <br />

.<br />

This file should be saved as app/views/index/index.blade.php.<br />

If you’ve created all of these files (and configured your web server to serve the Laravel application)<br />

then you should see a set of controls in your browser, when you visit /. Before we move on; let’s just<br />

quickly set up a socket server for this interface to talk to the PHP server with….<br />

Creating A Socket Server<br />

We’ve covered this topic before; so I won’t go into too much detail. We’re going to set up a Ratchet<br />

socket server, to pass messages back and forth between the interface and the PHP server.<br />

1 try {<br />

2 if (!WebSocket) {<br />

3 console.log("no websocket support");<br />

4 } else {<br />

5<br />

6 var socket = new WebSocket("ws://127.0.0.1:8081/");<br />

7<br />

8 socket.addEventListener("open", function (e) {<br />

9 console.log("open: ", e);<br />

10 });<br />

11<br />

12 socket.addEventListener("error", function (e) {<br />

13 // console.log("error: ", e);<br />

14 });<br />

15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!