示例#1
0
        void Slave_Connection_OnMessage(Slave_Connection SC, System.Xml.Linq.XElement xMsg)
        {
            // This event is called from an independent thread belonging to the particular slave.

            #if DEBUG
            // In the startup debugging phase, intercept anything and queue it for later.
            if (StartupDebugging)
            {
                lock (this) { DebugQueue.Enqueue(new Tuple <Slave_Connection, System.Xml.Linq.XElement>(SC, xMsg)); } return;
            }
            #endif

            Slave found = null;
            lock (Slaves)
            {
                foreach (Slave ss in Slaves)
                {
                    if (ss.Connection == SC)
                    {
                        found = ss;
                        break;
                    }
                }
            }

            if (found != null)
            //lock (found)
            {
                Terminal.OnMessage(found, xMsg);
                return;
            }

            throw new Exception("Slave not found in current connections list.");
        }
示例#2
0
 public void Dispose()
 {
     if (Connection != null)
     {
         Connection.Dispose(); Connection = null;
     }
     GC.SuppressFinalize(true);
 }
示例#3
0
 Slave FindSlave(Slave_Connection With_Connection)
 {
     foreach (Slave ss in Slaves)
     {
         if (ss.Connection == With_Connection)
         {
             return(ss);
         }
     }
     return(null);
 }
示例#4
0
 private void Slave_Connection_OnState(Slave_Connection SC, Slave_Connection.Connection_State NewState)
 {
     lock (StateQueueLock) StateChanges.Enqueue(new Tuple <Slave_Connection, Slave_Connection.Connection_State>(SC, NewState));
 }
示例#5
0
 public Slave(string HostName, RegistryCertificateStore AcceptedCertificates)
 {
     Connection = new Slave_Connection(HostName, AcceptedCertificates);
     lock (NextIDLock) { ID = NextID++; }
     DarkColor = DarkColors[ID % DarkColors.Length];
 }