私はいつでもどこでも必要としても、socket.io接続をモジュール式にして、一度実行させたいと思います。どのようにエクスポートするのですか?express.js(node.js)の混乱が必要となります。
var server = require("http").Server(express);
var io = require("socket.io")(server);
server.listen(5000);
io.on('connection', function(client) {
client.on('order_'+userId, function(data) {
io.emit('order_'+userId,data); // emit to cilent of dashboard
});
});
どのように必要ですか?私は、任意の変数に代入する必要はありません私の場合は
var moment = require('moment');
またはいつか
var LocalStorage = require('node-localstorage').LocalStorage;
のように異なるパターンを見て、それが即座に実行したいんです。可能?
[Node.js module.exportsの目的は何ですか?どうすれば使用できますか?](http://stackoverflow.com/questions/5311334/what-is-the-purpose-of-node -js-module-exports-and-how-do-use-it)を実行します。 – docksteaderluke