Пример #1
0
        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);
        }
Пример #2
0
        private void OnEvent(ConsoleEventType consoleEvent)
        {
            EventHandler <ConsoleControlEventArgs> handler = Event;

            if (handler != null)
            {
                handler(this, new ConsoleControlEventArgs(consoleEvent));
            }
        }
Пример #3
0
        private static bool OnConsoleEvent(ConsoleEventType type)
        {
            if (World.Saving)
            {
                return(true);
            }

            return(false);
        }
Пример #4
0
        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);
        }
Пример #5
0
        private static bool OnConsoleEvent(ConsoleEventType type)
        {
            if (World.Saving || (m_Service && type == ConsoleEventType.CTRL_LOGOFF_EVENT))
            {
                return(true);
            }

            Kill();

            return(true);
        }
Пример #6
0
        private static bool OnConsoleEvent(ConsoleEventType type)
        {
            if (type == ConsoleEventType.CTRL_LOGOFF_EVENT)
            {
                return(true);
            }

            Kill();

            return(true);
        }
Пример #7
0
        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));
            }
        }
Пример #8
0
        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);
        }
Пример #9
0
 public CommandEvent(ConsoleEventType type, string command)
 {
     Type    = type;
     Command = command;
 }
Пример #10
0
		public ConsoleControlEventArgs(ConsoleEventType eventType)
		{
			EventType = eventType;
		}
Пример #11
0
 private static bool OnConsoleEvent(ConsoleEventType type)
 {
     Shutdown();
     return(true);
 }
Пример #12
0
 public ConsoleEvent(ConsoleEventType type, string format, params object[] args)
 {
     EventType = type;
     Message   = string.Format(format, args);
 }
Пример #13
0
 public ConsoleEvent(ConsoleEventType type, string message)
 {
     EventType = type;
     Message   = message;
 }
Пример #14
0
		private static bool OnConsoleEvent(ConsoleEventType type) {
			if (type == ConsoleEventType.CTRL_LOGOFF_EVENT)
				return true;

			Kill();

			return true;
		}
Пример #15
0
 public ConsoleControlEventArgs(ConsoleEventType eventType)
 {
     EventType = eventType;
 }
Пример #16
0
 public ConsoleHandlerEventArgs(ConsoleEventType type)
 {
     this.Type = type;
 }
Пример #17
0
 private void OnEvent(ConsoleEventType consoleEvent)
 {
     EventHandler<ConsoleControlEventArgs> handler = Event;
     if (handler != null)
     {
         handler(this, new ConsoleControlEventArgs(consoleEvent));
     }
 }
Пример #18
0
 public static void WriteLine(object value, ConsoleEventType color)
 {
     Console.ForegroundColor = (ConsoleColor)color;
     Console.WriteLine(value);
     Console.ResetColor();
 }
Пример #19
0
        /// <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);
        }
Пример #20
0
            private static bool OnConsoleEvent(ConsoleEventType type)
            {
                Close();

                return true;
            }
Пример #21
0
            private static bool OnConsoleEvent(ConsoleEventType type)
            {
                Close();

                return(true);
            }
Пример #22
0
        private static bool OnConsoleEvent( ConsoleEventType type )
        {
            if ( World.Saving )
                return true;

            return false;
        }
Пример #23
0
		private static bool OnConsoleEvent( ConsoleEventType type )
		{
			if( World.Saving || ( m_Service && type == ConsoleEventType.CTRL_LOGOFF_EVENT ) )
				return true;
			
			Kill();

			return true;
		}
Пример #24
0
        /// <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;
        }
Пример #25
0
		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;
		}
Пример #26
0
 private void OnEvent(ConsoleEventType consoleEvent)
 {
     Event?.Invoke(this, new ConsoleControlEventArgs(consoleEvent));
 }