This repository has been archived on 2018-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
node-task/node_modules/mysql2/lib/server.js

32 lines
1.0 KiB
JavaScript
Raw Normal View History

2014-09-24 17:56:53 -04:00
var net = require('net');
var util = require('util');
var EventEmitter = require('events').EventEmitter;
var PacketParser = require('./packet_parser');
var Packet = require('./packets/packet');
var Commands = require('./commands/index.js');
var Connection = require('./connection');
var ConnectionConfig = require('./connection_config');
// TODO: inherit Server from net.Server
function Server()
{
EventEmitter.call(this);
this.connections = [];
this._server = net.createServer(this._handleConnection.bind(this));
}
util.inherits(Server, EventEmitter);
Server.prototype._handleConnection = function(socket) {
var connectionConfig = new ConnectionConfig({ stream: socket, isServer: true});
var connection = new Connection({ config: connectionConfig});
this.emit('connection', connection);
this.connections.push(connection);
};
Server.prototype.listen = function(port, host, backlog, callback) {
this._server.listen(port, host, backlog, callback);
};
module.exports = Server;