Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
I am looking for a way to send commands through the command line in Terminal. I am already using Socket.IO. – jskidd3 5 hours ago
I can't imagine any scenario where that would ever be useful. Wouldn't you prefer a chat window? – Robert Harvey 5 hours ago
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 here – jskidd3 5 hours ago
Have you already figured out how to send a message to all players using Socket.IO? – Robert Harvey 5 hours ago
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 5 hours ago
show 3 more comments

1 Answer

up vote 1 down vote accepted

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');
share|improve this answer
This is really nothing more than a link, and might be better suited as a comment. – Matt 5 hours ago
@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. – C.Hazelton 5 hours ago
"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. – Matt 5 hours ago
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. – C.Hazelton 5 hours ago
Thanks guys, this is perfect Matt! :) – jskidd3 5 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.