Added the missing server folder

This commit is contained in:
Franck Cornu 2016-10-24 13:11:22 -04:00
parent 6af238ce2e
commit 6110b73fcf
4 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,2 @@
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\4.6.0\node.exe"
debuggingEnabled: true

View File

@ -0,0 +1 @@
<h1>SPFx with Socket IO demo</h1>

View File

@ -0,0 +1,17 @@
{
"name": "spfx-socket.io",
"author": {
"name": "Franck Cornu @FranckCornu (http://thecollaborationcorner.com)"
},
"version": "1.0.0",
"private": true,
"scripts": {
"start": "node server"
},
"license": "Apache",
"dependencies": {
"azure": "^1.2.0-preview",
"express": "^4.14.0",
"socket.io": "^1.4.8"
}
}

View File

@ -0,0 +1,32 @@
// Port will be assigned automatically by the Azure Web App (rocess.env.port ). For localhost debugging, we use 8080.
// You can use the built-in Visual Studio Code debugger to test the solution locally.
var port = process.env.port || 8080;
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
var azure = require('azure');
server.listen(port);
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
// Service Bus Connection string is retrieved from the app env app settings
var serviceBusService = azure.createServiceBusService(process.env.AZURE_SERVICEBUS_ACCESS_KEY);
// Listener function to pull the Azure service bus and see if new messages are available
setInterval(function() {
serviceBusService.receiveQueueMessage('news', function(error, message){
if(!error) {
// Message received and deleted (default behavior of the service bus)
console.log(message);
// Broadcast to all connected clients
io.emit('item:added', message );
}
});
}, 5 );