public ConsoleCommandResponse Help() { var response = new ConsoleCommandResponse(); foreach (var o in _commands) { response.AppendMessage(PrettyFormat(o)); } return response; }
public ConsoleCommandResponse Echo(string content) { if(string.IsNullOrEmpty(content)) //Throw an error if we're missing content { throw new CommandArgumentException("Invalid command - missing argument for echo {phrase_to_be_echoed}"); } var response = new ConsoleCommandResponse(); response.AppendMessage(content); _session.SendResponseAsync(response.Serialize()); return response; }
public ConsoleCommandResponse NetSend(string target, string content) { var response = new ConsoleCommandResponse(); response.AppendMessage(string.Format("Message from [{0}]", _session.SessionID)); response.AppendMessage(content); if (_sendAllMethod == null) { //Send the result back to just the current user _session.SendResponseAsync(response.Serialize()); } else { _sendAllMethod.Invoke(response.Serialize()); } return response; }
void socketServer_NewMessageReceived(WebSocketSession session, string e) { var command = JsonConvert.DeserializeObject<ConsoleCommand>(e); try { IConsoleResponder r = new ConsoleResponder(SendToAll); r.ProcessResponse(command, session); } catch(Exception ex) { var response = new ConsoleCommandResponse(); response.AppendMessage("Server Error! :("); response.AppendMessage(ex.Message); session.SendResponseAsync(response.Serialize()); } }