Index: web/testserver/LICENSE =================================================================== --- web/testserver/LICENSE (nonexistent) +++ web/testserver/LICENSE (revision 4930) @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 Kalman Keri + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. Index: web/testserver/README =================================================================== --- web/testserver/README (nonexistent) +++ web/testserver/README (revision 4930) @@ -0,0 +1,29 @@ +testserver +========== + +Simple node.js webserver for websocket testing. + +The server serves static files in the ../testclient directory. +There is a websocket server listening at `/echo`, which simply echoes received +messages. + + +Preconditions +------------- +Install node.js v4.x.x or higher (v6.x.x is recommended). +Install the npm package manager. +Run `npm install` in the testserver directory. + + +Starting the server +------------------- +To start the server use the `npm start` command. +The server is listening on port 3000 by default. +The port can be overridden by setting the `port` environment variable. + + +Manual clean up +--------------- + +The node_modules subdirectory can be deleted manually. +No other artifacts are created. Index: web/testserver/app.js =================================================================== --- web/testserver/app.js (nonexistent) +++ web/testserver/app.js (revision 4930) @@ -0,0 +1,28 @@ +var express = require('express'); +var morgan = require('morgan'); + +var app = express(); +var expressWs = require('express-ws')(app); + +app.use(express.static("../testclient")); +app.use(morgan("common")); + +app.get('/', function (req, res, next) { + console.log('get route', req.testing); + res.end(); +}); + +app.ws('/echo', function (ws, req) { + console.log("open echo socket"); + ws.on("message", function (msg) { + console.log("echo", msg); + ws.send(msg); + }); + ws.on("close", function () { + console.log("close echo socket"); + }); +}); + +var server = app.listen(process.env.port || 3000, function () { + console.log('testserver listening on port', server.address().port); +}); Index: web/testserver/package.json =================================================================== --- web/testserver/package.json (nonexistent) +++ web/testserver/package.json (revision 4930) @@ -0,0 +1,17 @@ +{ + "name": "testserver", + "version": "0.0.0", + "private": true, + "scripts": { + "start": "node ./app" + }, + "description": "testserver", + "author": { + "name": "Kalman Keri" + }, + "dependencies": { + "express": "~4.9.0", + "express-ws": "^2.0.0", + "morgan": "^1.7.0" + } +}