Created
January 3, 2015 17:16
-
-
Save aaronbartell/67c5fa28abe86a701ad0 to your computer and use it in GitHub Desktop.
Git server on IBM i using Node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('/QOpenSys/QIBM/ProdData/Node/bin/node_modules/express'); | |
var app = express(); | |
var server = require('http').createServer(app); | |
var io = require('/QOpenSys/QIBM/ProdData/Node/bin/node_modules/socket.io').listen(server); | |
var conf = {"port": 8020}; | |
app.use("/css", express.static(__dirname + '/css')); | |
app.get('/', function(request, response) { | |
response.sendfile(__dirname + '/html/index_chat.htm'); | |
}); | |
server.listen(conf.port); | |
io.sockets.on('connection', function(socket) { | |
socket.emit('chat', {zeit: new Date(), text: 'You are connected with the server!'}); | |
socket.on('chat', function(data) { | |
io.sockets.emit('chat', {zeit: new Date(), name: data.name || 'Anonym', text: data.text}); | |
}); | |
}); | |
console.log('Server running:' + conf.port + '/'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment