是的所以我正在观看rm2kdev关于制作mmorpg的视频系列节目,我得到了一个特定点,我有这个。
require(__dirname + '/Resources/config.js');
var fs = require('fs');
var net = require('net');
require('./packet.js')
//1. load the initializers
var init_files = fs.readdirSync(__dirname + "/Initializers");
init_files.forEach(function(initFile){
console.log('Loading Initializer: ' + initFile);
require(__dirname + "/Initializers/" + initFile);
});
//2. load data models
var model_files = fs.readdirSync(__dirname + "/Models");
model_files.forEach(function(modelFile){
console.log('Loading Model: ' + modelFile);
require(__dirname + "/Models/" + modelFile);
});
//3. load game maps data
maps = {};
var map_files = fs.readdirSync(config.data_paths.maps);
map_files.forEach(function(mapFile){
console.log('Loading Map: ' + mapFile);
var map = require(config.data_paths.maps + mapFile);
maps[map.room] = map
});
//4. initiate the server and listen to the internets
net.createServer(function(socket){
console.log("socket connected");
var c_inst = new require('./client.js');
var thisClient = new c_inst();
thisClient.socket = socket;
thisClient.initiate();
socket.on('error', thisClient.error);
socket.on('end', thisClient.end);
socket.on('data', thisClient.data);
}).listen(config.port, '127.0.0.1');
console.log("Initialize Completed, Server running on port: " + config.port + " for environment: " + config.environment);
这是我的server.js文件,而且//是评论。我把它留在那里。当我运行服务器时,一切运行正常。但是当我运行客户端时,它说听众必须是一个功能,并且如何解决这个问题并且我无法在互联网上找到答案。所以一些帮助会非常好。