Permalink
Browse files

Merge pull request #11 from christav/spew-slurp-23

Building out stress app
  • Loading branch information...
2 parents 90dfc4b + a90a600 commit 10ddf67fb84b8b0200eced76f7fedd6a5de117a2 @christav christav committed Mar 7, 2013
View
@@ -0,0 +1,74 @@
+/**
+* Copyright (c) Microsoft. All rights reserved.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+/**
+ * Module dependencies.
+ */
+
+var express = require('express')
+ , routes = require('./routes')
+ , http = require('http')
+ , path = require('path')
+ , sio = require('socket.io');
+
+var app = express();
+
+app.configure(function(){
+ app.set('port', process.env.PORT || 3000);
+ app.set('views', __dirname + '/views');
+ app.set('view engine', 'jade');
+ app.use(express.favicon());
+ app.use(express.logger('dev'));
+ app.use(express.bodyParser());
+ app.use(express.methodOverride());
+ app.use(app.router);
+ app.use(express.static(path.join(__dirname, 'public')));
+});
+
+app.configure('development', function(){
+ app.use(express.errorHandler());
+});
+
+app.get('/', routes.index);
+app.get('/sender', routes.sender);
+app.get('/receiver', routes.receiver);
+
+var server = http.createServer(app);
+
+server.listen(app.get('port'), function(){
+ console.log("Express server listening on port " + app.get('port'));
+});
+
+var io = sio.listen(server);
+io.configure(function () {
+ io.set('log level', 0);
+});
+
+io.sockets.on('connection', function (socket) {
+ socket.on('start', function (settings) {
+ // TODO: Add server settings here
+ socket.broadcast.emit('start', settings);
+ });
+
+ socket.on('test', function (timeSent, body) {
+ socket.broadcast.emit('test', timeSent, Date.now(), body);
+ });
+
+ socket.on('stop', function () {
+ socket.broadcast.emit('stop');
+ });
+});
@@ -0,0 +1,13 @@
+{
+ "name": "application-name",
+ "version": "0.0.1",
+ "private": true,
+ "scripts": {
+ "start": "node app"
+ },
+ "dependencies": {
+ "express": "3.0.0rc5",
+ "jade": "*",
+ "socket.io": "~0.9.13"
+ }
+}
Oops, something went wrong.

0 comments on commit 10ddf67

Please sign in to comment.