private bool ReadData(ref ConsoleEventType id, ref string data) { try { NetworkStream stream = _clientSocket.GetStream(); int ret = 0; while (true) { ret += stream.Read(_inStream, ret, Constants.DefaultBuffer - ret); if (ret == 0) { return(false); } if (_inStream[ret - 1] == '\0') { break; } } string returndata = System.Text.Encoding.ASCII.GetString(_inStream); id = (ConsoleEventType)(returndata[0] - '0'); int index = returndata.IndexOf('\0'); data = returndata.Substring(1, index - 1); } catch (Exception) { return(false); } return(true); }
private void OnEvent(ConsoleEventType consoleEvent) { EventHandler <ConsoleControlEventArgs> handler = Event; if (handler != null) { handler(this, new ConsoleControlEventArgs(consoleEvent)); } }
private static bool OnConsoleEvent(ConsoleEventType type) { if (World.Saving) { return(true); } return(false); }
private static bool OnConsoleEvent(ConsoleEventType type) { if (World.Saving || (Service && type == ConsoleEventType.CTRL_LOGOFF_EVENT)) { return(true); } Kill(); //Kill -> HandleClosed will handle waiting for the completion of flushing to disk return(true); }
private static bool OnConsoleEvent(ConsoleEventType type) { if (World.Saving || (m_Service && type == ConsoleEventType.CTRL_LOGOFF_EVENT)) { return(true); } Kill(); return(true); }
private static bool OnConsoleEvent(ConsoleEventType type) { if (type == ConsoleEventType.CTRL_LOGOFF_EVENT) { return(true); } Kill(); return(true); }
private bool ProcessClient() { ConsoleEventType eventType = ConsoleEventType.Noop; string data = ""; if (!ReadData(ref eventType, ref data)) { return(false); } switch (eventType) { case ConsoleEventType.LogMessage: AddLogMessage(MessageType.Message, data); return(SendData(ConsoleEventType.Noop)); case ConsoleEventType.LogWarning: AddLogMessage(MessageType.Warning, data); return(SendData(ConsoleEventType.Noop)); case ConsoleEventType.LogError: AddLogMessage(MessageType.Error, data); return(SendData(ConsoleEventType.Noop)); case ConsoleEventType.AutoCompleteList: AddAutoCompleteItem(data); return(SendData(ConsoleEventType.Noop)); case ConsoleEventType.AutoCompleteListDone: AutoCompleteDone(); return(SendData(ConsoleEventType.Noop)); case ConsoleEventType.Req: CommandEvent command = null; if (GetCommand(ref command)) { return(SendData(command.Type, command.Command)); } else { return(SendData(ConsoleEventType.Noop)); } default: return(SendData(ConsoleEventType.Noop)); } }
private bool SendData(ConsoleEventType id, string data = "") { char cid = (char)((char)id + '0'); string msg = ""; msg += cid; msg += data; msg += "\0"; try { byte[] outStream = System.Text.Encoding.ASCII.GetBytes(msg); NetworkStream stream = _clientSocket.GetStream(); stream.Write(outStream, 0, outStream.Length); stream.Flush(); } catch (Exception) { return(false); } return(true); }
public CommandEvent(ConsoleEventType type, string command) { Type = type; Command = command; }
public ConsoleControlEventArgs(ConsoleEventType eventType) { EventType = eventType; }
private static bool OnConsoleEvent(ConsoleEventType type) { Shutdown(); return(true); }
public ConsoleEvent(ConsoleEventType type, string format, params object[] args) { EventType = type; Message = string.Format(format, args); }
public ConsoleEvent(ConsoleEventType type, string message) { EventType = type; Message = message; }
private static bool OnConsoleEvent(ConsoleEventType type) { if (type == ConsoleEventType.CTRL_LOGOFF_EVENT) return true; Kill(); return true; }
public ConsoleHandlerEventArgs(ConsoleEventType type) { this.Type = type; }
private void OnEvent(ConsoleEventType consoleEvent) { EventHandler<ConsoleControlEventArgs> handler = Event; if (handler != null) { handler(this, new ConsoleControlEventArgs(consoleEvent)); } }
public static void WriteLine(object value, ConsoleEventType color) { Console.ForegroundColor = (ConsoleColor)color; Console.WriteLine(value); Console.ResetColor(); }
/// <summary> /// Delegate method that gets called when console application events occur. /// </summary> private static bool HandleConsoleWindowEvents(ConsoleEventType controlType) { // ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.WIN32COM.v10.en/dllproc/base/handlerroutine.htm // When this function does not return True, the default handler is called and the default action takes // place. switch (controlType) { case ConsoleEventType.CancelKeyPress: CancelEventArgs ctrlCKeyPressEventData = new CancelEventArgs(); if ((object)CancelKeyPress != null) { CancelKeyPress(null, ctrlCKeyPressEventData); } if (ctrlCKeyPressEventData.Cancel) { return(true); } break; case ConsoleEventType.BreakKeyPress: CancelEventArgs ctrlBreakKeyPressEventData = new CancelEventArgs(); if ((object)BreakKeyPress != null) { BreakKeyPress(null, ctrlBreakKeyPressEventData); } if (ctrlBreakKeyPressEventData.Cancel) { return(true); } break; case ConsoleEventType.ConsoleClosing: CancelEventArgs consoleClosingEventData = new CancelEventArgs(); if ((object)ConsoleClosing != null) { ConsoleClosing(null, consoleClosingEventData); } if (consoleClosingEventData.Cancel) { return(true); } break; case ConsoleEventType.UserLoggingOff: if ((object)UserLoggingOff != null) { UserLoggingOff(null, EventArgs.Empty); } break; case ConsoleEventType.SystemShutdown: if ((object)SystemShutdown != null) { SystemShutdown(null, EventArgs.Empty); } break; } return(false); }
private static bool OnConsoleEvent(ConsoleEventType type) { Close(); return true; }
private static bool OnConsoleEvent(ConsoleEventType type) { Close(); return(true); }
private static bool OnConsoleEvent( ConsoleEventType type ) { if ( World.Saving ) return true; return false; }
private static bool OnConsoleEvent( ConsoleEventType type ) { if( World.Saving || ( m_Service && type == ConsoleEventType.CTRL_LOGOFF_EVENT ) ) return true; Kill(); return true; }
/// <summary> /// Delegate method that gets called when console application events occur. /// </summary> private static bool HandleConsoleWindowEvents(ConsoleEventType controlType) { // ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.WIN32COM.v10.en/dllproc/base/handlerroutine.htm // When this function does not return True, the default handler is called and the default action takes // place. switch (controlType) { case ConsoleEventType.CancelKeyPress: CancelEventArgs ctrlCKeyPressEventData = new CancelEventArgs(); if ((object)CancelKeyPress != null) CancelKeyPress(null, ctrlCKeyPressEventData); if (ctrlCKeyPressEventData.Cancel) return true; break; case ConsoleEventType.BreakKeyPress: CancelEventArgs ctrlBreakKeyPressEventData = new CancelEventArgs(); if ((object)BreakKeyPress != null) BreakKeyPress(null, ctrlBreakKeyPressEventData); if (ctrlBreakKeyPressEventData.Cancel) return true; break; case ConsoleEventType.ConsoleClosing: CancelEventArgs consoleClosingEventData = new CancelEventArgs(); if ((object)ConsoleClosing != null) ConsoleClosing(null, consoleClosingEventData); if (consoleClosingEventData.Cancel) return true; break; case ConsoleEventType.UserLoggingOff: if ((object)UserLoggingOff != null) UserLoggingOff(null, EventArgs.Empty); break; case ConsoleEventType.SystemShutdown: if ((object)SystemShutdown != null) SystemShutdown(null, EventArgs.Empty); break; } return false; }
private static bool OnConsoleEvent(ConsoleEventType type) { if (World.Saving || (m_Service && type == ConsoleEventType.CTRL_LOGOFF_EVENT)) { return true; } Kill(); //Kill -> HandleClosed will handle waiting for the completion of flushing to disk return true; }
private void OnEvent(ConsoleEventType consoleEvent) { Event?.Invoke(this, new ConsoleControlEventArgs(consoleEvent)); }