Antoine, this seems very interesting! Do you have any example code?
On Sunday, June 30, 2013 9:51:21 AM UTC-3, Antoine wrote: > > Create separate "service" modules which are completely unaware of > socket.io, which accept hooks/callbacks; then in your socket.js wire them > together. > > For example for your chat, create a module which does the room creation / > chatting / joining etc and let it do callbacks whenever a room is created / > somebody says something / etc. This should keep your socket.js file down to > a minimum and at the same time lead to more flexible, reusable code. > > Then if your socket.js file is still too long you can further break it > down as suggested by Duncan, but personally I would keep the wiring in a > single file. > > > > Antoine > > > > > > > On Sun, Jun 30, 2013 at 12:38 PM, Duncan Wilkie > <duncanan...@gmail.com<javascript:> > > wrote: > >> Pass the socket.io variable around as a parameter to other files / >> components >> var io = socket.io >> >> require('./component1.js')(io) >> >> ... >> // component1.js >> module.exports = function (io) { >> // logic >> } >> — >> Sent from Mailbox <https://www.dropbox.com/mailbox> for iPhone >> >> >> On Sun, Jun 30, 2013 at 10:40 AM, Mike Chen <mikal...@gmail.com<javascript:> >> > wrote: >> >>> Hi guys, >>> >>> I'm pretty new to Node.JS and socket IO, so I was wondering if I could >>> get some guidance on project I'm working on. I would like to build a single >>> page multiplayer game that basically communicates solely through socket.IO. >>> >>> However, I am quickly seeing that my socket.js file is getting very >>> clumsy. I am using express to manage the MVC side of things, but I feel >>> like socket connections don't really fit in the MVC paradigm. >>> >>> I have read a bunch of tutorials on node JS and socket IO, but all of >>> them have small socket components. >>> >>> Essentially I am wondering how to break down a large socket.js file into >>> smaller more manageable components? For example, I have a chat room in the >>> page, as well as the game part, and some meta game aspects. I don't feel >>> like these all belong in the same socket.js file, but it doesnt seem clean >>> to divide them in separate files either because you need access to the >>> client and the socket object ( to emit to all users in a room lets say) >>> >>> Thanks >>> >>> >>> >>> -- >>> -- >>> Job Board: http://jobs.nodejs.org/ >>> Posting guidelines: >>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >>> You received this message because you are subscribed to the Google >>> Groups "nodejs" group. >>> To post to this group, send email to nod...@googlegroups.com<javascript:> >>> To unsubscribe from this group, send email to >>> nodejs+un...@googlegroups.com <javascript:> >>> For more options, visit this group at >>> http://groups.google.com/group/nodejs?hl=en?hl=en >>> >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "nodejs" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to nodejs+un...@googlegroups.com <javascript:>. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> -- >> -- >> Job Board: http://jobs.nodejs.org/ >> Posting guidelines: >> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >> You received this message because you are subscribed to the Google >> Groups "nodejs" group. >> To post to this group, send email to nod...@googlegroups.com<javascript:> >> To unsubscribe from this group, send email to >> nodejs+un...@googlegroups.com <javascript:> >> For more options, visit this group at >> http://groups.google.com/group/nodejs?hl=en?hl=en >> >> --- >> You received this message because you are subscribed to the Google Groups >> "nodejs" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to nodejs+un...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.