var https = require('https');
var fs = require('fs');
var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({
host: 'localhost:9200'/*,
log: 'trace'*/
});
var options = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
};
var serverhttps = https.createServer(options, function (req, res) {});
var io = require('socket.io').listen(serverhttp);
io.set('origins', '*:*');
// Quand on client se connecte
io.sockets.on('connection', function (socket) {
console.log('Connecte');
// Quand on reçoit un appel search
socket.on('search', function (obj) {
client.search(obj.searchQuery, function (error, reponse) {
socket.emit('returnResultElasticsearch', {'searchType':obj.searchType, 'searchResult':reponse});
});
});
// Quand on reçoit un appel suggest
socket.on('suggest', function (obj) {
client.suggest(obj.suggestQuery, function (error, reponse) {
socket.emit('returnResultAutoCompletion', {'suggestType':obj.suggestType, 'suggestResult':reponse});
});
});
});
serverhttp.listen(8080, "0.0.0.0");
--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/0ab19fd4-4903-481f-9ff2-18fbf639c983%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.