Ejemplo n.º 1
0
        private void ServerLoop(object sender, DoWorkEventArgs e)
        {
            if (!Connection.StartConnection(CurrentConfig))
            {
                OnConnectionClosed(false);
                return;
            }

            State = PopState.Authorization;
            OnConnectionOpened();

            while (!ShutdownRequested)
            {
                if (CommandQueue.Count > 0)
                {
                    PopCommand Cmd = null;
                    bool       Deq = CommandQueue.TryDequeue(out Cmd);
                    if (!Connection.ExecuteCommand(Cmd))
                    {
                        OnLineSentOrReceived(false, "PopCommand error for " + Cmd.ToString());
                    }
                    System.Threading.Thread.Sleep(100);
                }
                else
                {
                    System.Threading.Thread.Sleep(100);
                }
            }

            ShutdownRequested = false;
            Connection.CloseConnection();
            Connection = null;
            OnConnectionClosed(State == PopState.Off);
        }
Ejemplo n.º 2
0
 public void PushNewCommand(PopCommand NewCommand)
 {
     NewCommand.SetPopService(this);
     CommandQueue.Enqueue(NewCommand);
 }