日期:2014-05-16 浏览次数:20305 次
var Net = require('net')
//var ProtoBuf = require("protobufjs");
var ServerSock = require('./SvrSocket');
var server = Net.createServer( onConnected );
server.listen(20660, function() {
console.log(' server running...');
});
function onConnected( socket ){
console.log('connected..');
var serverSocket = ServerSock.createSvrSocket(null);
serverSocket.setSocket( socket );
}
module.exports =
{
createSvrSocket : function( socket)
{
return new SvrSocket(socket);
},
}
function SvrSocket( socket )
{
this.m_Socket = socket;
}
SvrSocket.prototype.onData = function( buffer )
{
//this.foo();
}
SvrSocket.prototype.setSocket = function( socket ) {
this.m_Socket = socket;
this.m_Socket.on('data', this.onData );
this.foo();
}
SvrSocket.prototype.foo = function() {
}
module.exports =
{
createSvrSocket : function( socket)
{
return new SvrSocket(socket);
},
}
function SvrSocket( socket )
{
this.m_Socket = socket;
}
SvrSocket.prototype.onData = function( buffer )
{
this.foo();
}
SvrSocket.prototype.setSocket = function( socket ) {
this.m_Socket = socket;
this.m_Socket.on('data', this.onData );
//this.foo();
}
SvrSocket.prototype.foo = function() {
}