websocket stuff

This commit is contained in:
Martin Donnelly 2016-02-17 12:10:27 +00:00
parent 864820ea34
commit a8a34fe1ed
3 changed files with 47 additions and 37 deletions

View File

@ -3,8 +3,8 @@
<component name="ChangeListManager">
<list default="true" id="8a985735-5aff-47ce-a55f-2957d4f9c5f9" name="Default" comment="websocket stuff">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/package.json" afterPath="$PROJECT_DIR$/package.json" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/routes/temp.js" afterPath="$PROJECT_DIR$/routes/temp.js" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/views/temp.ejs" afterPath="$PROJECT_DIR$/views/temp.ejs" />
</list>
<ignored path="silvrapi.iws" />
<ignored path=".idea/workspace.xml" />
@ -25,11 +25,11 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="temp.ejs" pinned="false" current-in-tab="true">
<file leaf-file-name="temp.ejs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/views/temp.ejs">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.28767124">
<caret line="104" column="47" selection-start-line="104" selection-start-column="47" selection-end-line="104" selection-end-column="47" />
<state vertical-scroll-proportion="-1.6666666">
<caret line="96" column="4" selection-start-line="96" selection-start-column="4" selection-end-line="96" selection-end-column="4" />
<folding />
</state>
</provider>
@ -45,11 +45,11 @@
</provider>
</entry>
</file>
<file leaf-file-name="temp.js" pinned="false" current-in-tab="false">
<file leaf-file-name="temp.js" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/routes/temp.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-4.6842103">
<caret line="140" column="41" selection-start-line="140" selection-start-column="41" selection-end-line="140" selection-end-column="41" />
<state vertical-scroll-proportion="0.45933014">
<caret line="16" column="21" selection-start-line="16" selection-start-column="21" selection-end-line="16" selection-end-column="21" />
<folding />
</state>
</provider>
@ -109,10 +109,10 @@
<entry file="file://$PROJECT_DIR$/package.json">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="23" column="0" selection-start-line="23" selection-start-column="0" selection-end-line="23" selection-end-column="0" />
<caret line="24" column="0" selection-start-line="24" selection-start-column="0" selection-end-line="24" selection-end-column="0" />
<folding>
<marker date="1455705724595" expanded="true" signature="78:113" placeholder="{&quot;start&quot;: &quot;node ./bin/www&quot;...}" />
<marker date="1455705724595" expanded="true" signature="133:375" placeholder="{&quot;body-parser&quot;: &quot;~1.13.2&quot;...}" />
<marker date="1455710778638" expanded="true" signature="78:113" placeholder="{&quot;start&quot;: &quot;node ./bin/www&quot;...}" />
<marker date="1455710778638" expanded="true" signature="133:395" placeholder="{&quot;body-parser&quot;: &quot;~1.13.2&quot;...}" />
</folding>
</state>
</provider>
@ -156,8 +156,8 @@
<option value="$PROJECT_DIR$/routes/time.js" />
<option value="$PROJECT_DIR$/newapp.js" />
<option value="$PROJECT_DIR$/public/stylesheets/tables.css" />
<option value="$PROJECT_DIR$/routes/temp.js" />
<option value="$PROJECT_DIR$/views/temp.ejs" />
<option value="$PROJECT_DIR$/routes/temp.js" />
</list>
</option>
</component>
@ -462,12 +462,6 @@
<option name="number" value="Default" />
<updated>1447021065296</updated>
</task>
<task id="LOCAL-00004" summary="closing db to persist&#10;">
<created>1447056652943</created>
<option name="number" value="00004" />
<option name="project" value="LOCAL" />
<updated>1447056652943</updated>
</task>
<task id="LOCAL-00005" summary="trying to persist the db">
<created>1447067474637</created>
<option name="number" value="00005" />
@ -756,7 +750,13 @@
<option name="project" value="LOCAL" />
<updated>1455709929591</updated>
</task>
<option name="localTasksCounter" value="53" />
<task id="LOCAL-00053" summary="websocket stuff">
<created>1455710379025</created>
<option name="number" value="00053" />
<option name="project" value="LOCAL" />
<updated>1455710379025</updated>
</task>
<option name="localTasksCounter" value="54" />
<servers />
</component>
<component name="ToolWindowManager">
@ -769,10 +769,10 @@
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="npm" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2614108" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2614108" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.47095436" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32823366" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32780084" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.39958593" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
@ -858,8 +858,8 @@
<state vertical-scroll-proportion="0.0">
<caret line="20" column="0" selection-start-line="20" selection-start-column="0" selection-end-line="20" selection-end-column="0" />
<folding>
<marker date="1455705724595" expanded="true" signature="78:113" placeholder="{&quot;start&quot;: &quot;node ./bin/www&quot;...}" />
<marker date="1455705724595" expanded="true" signature="133:375" placeholder="{&quot;body-parser&quot;: &quot;~1.13.2&quot;...}" />
<marker date="1455710778638" expanded="true" signature="78:113" placeholder="{&quot;start&quot;: &quot;node ./bin/www&quot;...}" />
<marker date="1455710778638" expanded="true" signature="133:395" placeholder="{&quot;body-parser&quot;: &quot;~1.13.2&quot;...}" />
</folding>
</state>
</provider>
@ -937,8 +937,8 @@
<state vertical-scroll-proportion="0.0">
<caret line="20" column="0" selection-start-line="20" selection-start-column="0" selection-end-line="20" selection-end-column="0" />
<folding>
<marker date="1455705724595" expanded="true" signature="78:113" placeholder="{&quot;start&quot;: &quot;node ./bin/www&quot;...}" />
<marker date="1455705724595" expanded="true" signature="133:375" placeholder="{&quot;body-parser&quot;: &quot;~1.13.2&quot;...}" />
<marker date="1455710778638" expanded="true" signature="78:113" placeholder="{&quot;start&quot;: &quot;node ./bin/www&quot;...}" />
<marker date="1455710778638" expanded="true" signature="133:395" placeholder="{&quot;body-parser&quot;: &quot;~1.13.2&quot;...}" />
</folding>
</state>
</provider>
@ -1147,10 +1147,10 @@
<entry file="file://$PROJECT_DIR$/package.json">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="23" column="0" selection-start-line="23" selection-start-column="0" selection-end-line="23" selection-end-column="0" />
<caret line="24" column="0" selection-start-line="24" selection-start-column="0" selection-end-line="24" selection-end-column="0" />
<folding>
<marker date="1455705724595" expanded="true" signature="78:113" placeholder="{&quot;start&quot;: &quot;node ./bin/www&quot;...}" />
<marker date="1455705724595" expanded="true" signature="133:375" placeholder="{&quot;body-parser&quot;: &quot;~1.13.2&quot;...}" />
<marker date="1455710778638" expanded="true" signature="78:113" placeholder="{&quot;start&quot;: &quot;node ./bin/www&quot;...}" />
<marker date="1455710778638" expanded="true" signature="133:395" placeholder="{&quot;body-parser&quot;: &quot;~1.13.2&quot;...}" />
</folding>
</state>
</provider>
@ -1211,18 +1211,18 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/routes/temp.js">
<entry file="file://$PROJECT_DIR$/views/temp.ejs">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-4.6842103">
<caret line="140" column="41" selection-start-line="140" selection-start-column="41" selection-end-line="140" selection-end-column="41" />
<state vertical-scroll-proportion="-1.6666666">
<caret line="96" column="4" selection-start-line="96" selection-start-column="4" selection-end-line="96" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/views/temp.ejs">
<entry file="file://$PROJECT_DIR$/routes/temp.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.28767124">
<caret line="104" column="47" selection-start-line="104" selection-start-column="47" selection-end-line="104" selection-end-column="47" />
<state vertical-scroll-proportion="0.45933014">
<caret line="16" column="21" selection-start-line="16" selection-start-column="21" selection-end-line="16" selection-end-column="21" />
<folding />
</state>
</provider>

View File

@ -14,7 +14,8 @@
"express": "~4.13.1",
"morgan": "~1.6.1",
"serve-favicon": "~2.3.0",
"websocket": "^1.0.22"
"websocket": "^1.0.22",
"ws": "^1.0.1"
},
"devDependencies": {
"log4js": "^0.6.31",

View File

@ -7,7 +7,7 @@ var router = express.Router();
var EventEmitter = require('events');
var busEmitter = new EventEmitter();
var WebSocketServer = require('websocket').server;
var WebSocketServer = require('ws').Server, wss = new WebSocketServer({ port: 8031 });
var temp_db;
var file = process.env.DB_HOME + '/' + "temp.db";
@ -136,8 +136,17 @@ var doInsertEvent = (obj) =>{
busEmitter.on('saveTempData', doInsertEvent);
// Socket Stuff
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
});
ws.send('something');
});
// Socket Stuff
/*
logger.info('Configuring WebSocket Listener...');
logger.trace('Creating server...');
var server = http.createServer(function (request, response) {
@ -199,4 +208,4 @@ wsServer.on('request', function (request) {
logger.debug((new Date()) + ' Peer ' + connection.remoteAddress + ' disconnected.');
busEmitter.removeListener('sendSocket', sendSocketHandler);
});
});;;;
});;;;*/