mirror of
https://github.com/mclueppers/xo-server.git
synced 2025-04-08 20:55:02 +02:00
Minor updates.
This commit is contained in:
parent
fd05a1a9cf
commit
22ce37c0cd
@ -94,8 +94,13 @@ Api.err = {
|
||||
|
||||
Api.fn = {};
|
||||
|
||||
Api.fn.session = {
|
||||
Api.fn.api = {
|
||||
'getVersion' : function (session, req, res) {
|
||||
return '0.1';
|
||||
},
|
||||
};
|
||||
|
||||
Api.fn.session = {
|
||||
'signInWithPassword': function (session, req, res) {
|
||||
var p_email = req.params.email;
|
||||
var p_pass = req.params.password;
|
||||
|
20
src/main.js
20
src/main.js
@ -1,3 +1,8 @@
|
||||
var events = require('events');
|
||||
var util = require('util');
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
var xo = require('./xo')();
|
||||
var api = require('./api')(xo);
|
||||
|
||||
@ -8,6 +13,12 @@ function Session()
|
||||
this.data = {};
|
||||
}
|
||||
|
||||
util.inherits(Session, events.EventEmitter);
|
||||
|
||||
Session.prototype.close = function () {
|
||||
session.emit('close');
|
||||
};
|
||||
|
||||
Session.prototype.get = function (name, def) {
|
||||
if (undefined !== this.data[name])
|
||||
{
|
||||
@ -40,6 +51,9 @@ Response.prototype.sendResult = function (value)
|
||||
'result': value,
|
||||
'id': this.id,
|
||||
}));
|
||||
|
||||
// Prevents results/errors to be sent more than once.
|
||||
delete this.transport;
|
||||
};
|
||||
|
||||
Response.prototype.sendError = function (error)
|
||||
@ -49,6 +63,9 @@ Response.prototype.sendError = function (error)
|
||||
'error': error,
|
||||
'id': this.id,
|
||||
}));
|
||||
|
||||
// Prevents results/errors to be sent more than once.
|
||||
delete this.transport;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@ -63,6 +80,9 @@ require('socket.io')
|
||||
};
|
||||
|
||||
var session = new Session();
|
||||
session.on('close', function () {
|
||||
socket.disconnect();
|
||||
});
|
||||
|
||||
// When a message is received.
|
||||
socket.on('message', function (message) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user