I'm running a node.js server using Terminal (Mac) and want to be able to emit messages to the client via the command line. Is this possible? I could code the messages part of it no problem, it's more how I can send something directly from the server to the client rather than from the client-server-client relationship I only understand at the moment.
-
I am looking for a way to send commands through the command line in Terminal. I am already using Socket.IO.jskidd3– jskidd32013-05-20 20:49:11 +00:00Commented May 20, 2013 at 20:49
-
I can't imagine any scenario where that would ever be useful. Wouldn't you prefer a chat window?Robert Harvey– Robert Harvey2013-05-20 20:50:47 +00:00Commented May 20, 2013 at 20:50
-
1@RobertHarvey I don't know what the best way of going about it would be. Imagine you're hosting some sort of game server, you can just send a command into the server window by saying something like: /say bla bla bla, that would broadcast to all players. That's what I'm looking to do herejskidd3– jskidd32013-05-20 20:51:55 +00:00Commented May 20, 2013 at 20:51
-
Have you already figured out how to send a message to all players using Socket.IO?Robert Harvey– Robert Harvey2013-05-20 20:53:19 +00:00Commented May 20, 2013 at 20:53
-
Yes I'm pretty advanced in terms of everything Socket.IO can do. I just want to be able to directly send messages from the server via my own input :)jskidd3– jskidd32013-05-20 20:54:36 +00:00Commented May 20, 2013 at 20:54
|
Show 3 more comments
1 Answer
This is probably what you're after if not let me know and I'll delete answer.
Look into a module called Commander found here.
It will allow you to build up a cli that you can then hook into your methods/prototypes etc.
For Matt :)
var program = require('commander');
program.option('-s, --send', 'Send command');
5 Comments
Matt
This is really nothing more than a link, and might be better suited as a comment.
origin1tech
@Matt he asked if it was possible and this is in fact how it can be done. what's your issue? If he asks another question I'll be happy to provide source.
Matt
"My issue" is as I said; this answer is nothing more than a link. I would expect information on how commander can be applied in his scenario, whether the OP specifically asks for it or not.
origin1tech
c'mon @Matt if he gave an example of a command you know I would and I just provided a very rudimentary example as I have zero to go off of. regardless this in fact answers the question.
jskidd3
Thanks guys, this is perfect Matt! :)