Leaderboards:
6 | jQuery7 | Ember
8 | Backbone
9 | Angular
10 |
7 | <%= error %>
8 |
9 |
10 | <% }) %>
11 |
12 |
13 |
--------------------------------------------------------------------------------
/config/routes.js:
--------------------------------------------------------------------------------
1 | // Routes
2 | // *********************
3 | //
4 | // This table routes urls to controllers/actions.
5 | //
6 | // If the URL is not specified here, the default route for a URL is: /:controller/:action/:id
7 | // where :controller, :action, and the :id request parameter are derived from the url
8 | //
9 | // If :action is not specified, Sails will redirect to the appropriate action
10 | // based on the HTTP verb: (using REST/Backbone conventions)
11 | //
12 | // GET: /:controller/read/:id
13 | // POST: /:controller/create
14 | // PUT: /:controller/update/:id
15 | // DELETE: /:controller/destroy/:id
16 | //
17 | // If the requested controller/action doesn't exist:
18 | // - if a view exists ( /views/:controller/:action.ejs ), Sails will render that view
19 | // - if no view exists, but a model exists, Sails will automatically generate a
20 | // JSON API for the model which matches :controller.
21 | // - if no view OR model exists, Sails will respond with a 404.
22 | //
23 | module.exports.routes = {
24 |
25 | // To route the home page to the "index" action of the "home" controller:
26 | '/' : {
27 | controller : 'home'
28 | }
29 |
30 | // If you want to set up a route only for a particular HTTP method/verb
31 | // (GET, POST, PUT, DELETE) you can specify the verb before the path:
32 | // 'post /signup': {
33 | // controller : 'user',
34 | // action : 'signup'
35 | // }
36 |
37 | // Keep in mind default routes exist for each of your controllers
38 | // So if you have a UserController with an action called "juggle"
39 | // a route will be automatically exist mapping it to /user/juggle.
40 | //
41 | // Additionally, unless you override them, new controllers will have
42 | // create(), find(), findAll(), update(), and destroy() actions,
43 | // and routes will exist for them as follows:
44 | /*
45 |
46 | // Standard RESTful routing
47 | // (if index is not defined, findAll will be used)
48 | 'get /user': {
49 | controller : 'user',
50 | action : 'index'
51 | },
52 | 'get /user/:id': {
53 | controller : 'user',
54 | action : 'find'
55 | },
56 | 'post /user': {
57 | controller : 'user',
58 | action : 'create'
59 | },
60 | 'put /user/:id': {
61 | controller : 'user',
62 | action : 'update'
63 | },
64 | 'delete /user/:id': {
65 | controller : 'user',
66 | action : 'destroy'
67 | }
68 | */
69 | };
70 |
--------------------------------------------------------------------------------
/SampleAppiOS/sampleApp/assets/js/app.js:
--------------------------------------------------------------------------------
1 | /**
2 | * app.js
3 | *
4 | * This file contains some conventional defaults for working with Socket.io + Sails.
5 | * It is designed to get you up and running fast, but is by no means anything special.
6 | *
7 | * Feel free to change none, some, or ALL of this file to fit your needs!
8 | */
9 |
10 |
11 | (function (io) {
12 |
13 | // as soon as this file is loaded, connect automatically,
14 | var socket = io.connect();
15 | if (typeof console !== 'undefined') {
16 | log('Connecting to Sails.js...');
17 | }
18 |
19 | socket.on('connect', function socketConnected() {
20 |
21 | // Listen for Comet messages from Sails
22 | socket.on('message', function messageReceived(message) {
23 |
24 | ///////////////////////////////////////////////////////////
25 | // Replace the following with your own custom logic
26 | // to run when a new message arrives from the Sails.js
27 | // server.
28 | ///////////////////////////////////////////////////////////
29 | log('New comet message received :: ', message);
30 | //////////////////////////////////////////////////////
31 |
32 | });
33 |
34 |
35 | ///////////////////////////////////////////////////////////
36 | // Here's where you'll want to add any custom logic for
37 | // when the browser establishes its socket connection to
38 | // the Sails.js server.
39 | ///////////////////////////////////////////////////////////
40 | log(
41 | 'Socket is now connected and globally accessible as `socket`.\n' +
42 | 'e.g. to send a GET request to Sails, try \n' +
43 | '`socket.get("/", function (response) ' +
44 | '{ console.log(response); })`'
45 | );
46 | ///////////////////////////////////////////////////////////
47 |
48 |
49 | });
50 |
51 |
52 | // Expose connected `socket` instance globally so that it's easy
53 | // to experiment with from the browser console while prototyping.
54 | window.socket = socket;
55 |
56 |
57 | // Simple log function to keep the example simple
58 | function log () {
59 | if (typeof console !== 'undefined') {
60 | console.log.apply(console, arguments);
61 | }
62 | }
63 |
64 |
65 | })(
66 |
67 | // In case you're wrapping socket.io to prevent pollution of the global namespace,
68 | // you can replace `window.io` with your own `io` here:
69 | window.io
70 |
71 | );
72 |
--------------------------------------------------------------------------------
/SampleAppiOS/SampleAppiOS/SocketIOPacket.m:
--------------------------------------------------------------------------------
1 | //
2 | // SocketIOPacket.h
3 | // v0.4 ARC
4 | //
5 | // based on
6 | // socketio-cocoa https://github.com/fpotter/socketio-cocoa
7 | // by Fred Potter
30 | 40 | Why might this be happening? 41 |
42 |
47 |
48 | You are currently viewing this with view engine: <% if (locals.defaultEngine) {;%><%- locals.defaultEngine %><%}%>
24 |Don't worry, we've got your back.
26 |33 | Run sails generate foo. This will create a model Foo and controller FooController 34 |
35 |44 | Run sails lift to start up your app. If you visit http://localhost:1337/foo in your browser, you'll see a socket.io-compatible REST API was generated for your 'Foo' model. 45 |
46 |From here, you can modify your models, create custom controller methods as Express middleware, and create custom routes (routes are set up in config/routes.js). Visit the Sails website for more information on next steps.
55 |