상속: ICommandable
예제 #1
0
 public override void VisitMessageArchive(MessageArchive messageArchive)
 {
     if (!messageArchive.TryPostMessage(ToArchive))
     {
         Debug.WriteLine("Tried to post to archive but it failed");
     }
 }
예제 #2
0
 public Dispatcher(TcpServer server, Registry registry, MessageArchive messageArchive)
 {
     Server = server;
     Registry = registry;
     MessageArchive = messageArchive;
     DispatchQueue = new BlockingCollection<Command>(new ConcurrentQueue<Command>());
     DispatchPreemptStack = new BlockingCollection<Command>(new ConcurrentStack<Command>());
     Log = Logger.GetInstance();
 }
예제 #3
0
 public override void VisitMessageArchive(MessageArchive messageArchive)
 {
     var msg = "MSG_QUERY_SUCCESS " + msgQSuc.Serialize();
     var toInst = messageArchive[msgQSuc.Id];
     if (toInst != null)
     {
         toInst.FromInstance.Send(msg);
     }
 }
예제 #4
0
        public void setup()
        {
            int hours = 0;
            int minutes = 0;
            int seconds = 1;

            archive = new MessageArchive(hours,minutes,seconds);
            testMsg = new StubMsgCommand();
            testMsg.guid = "TESTGUIDBECAUSSEITSASTRING";
        }
예제 #5
0
 /// <summary>
 /// Check if this guid is already in the message archive
 /// If the GUID given already exists in the archive the app instance
 /// is notified and HasValidGuid is set to false
 /// </summary>
 /// <param name="messageArchive">The archive to visit</param>
 public override void VisitMessageArchive(MessageArchive messageArchive)
 {
     if (messageArchive[this.guid] != null)
     {
         HasValidGuid = false;
         var genFail = new MsgGeneralFailure();
         genFail.Received = "";
         genFail.Message = "The guid " + this.guid + " was already taken";
         var msg = "MSG_GENERAL_FAILURE " + genFail.Serialize();
         FromInstance.Send(msg);
     }
     else
         HasValidGuid = true;
 }
예제 #6
0
        public override void VisitMessageArchive(MessageArchive messageArchive)
        {
            if (!messageArchive.TryPostMessage(this))
            {
                Debug.WriteLine("failed because message currently exists");
                var fail = new MsgGeneralFailure();
                fail.Message = "Message key '" + guid + "' currently exists in message archive, can't override";
                fail.FromInstanceId = FromInstance.InstanceId;
                fail.Received = "";

                FromInstance.Send("MSG_GENERAL_FAILURE " + fail.Serialize());

            }
        }
예제 #7
0
        static void Main(string[] args)
        {
            Log = Logger.GetInstance();

            Log.Info("Starting up");

            TcpServer server = null;

            if(UsingTls(args))
            {
                Log.Info("Using TLS");
                X509Certificate2 cert = null;
                var foundCert = TryGetX509Certificate(args, out cert);

                // We have a certificate, so create the server
                if (foundCert)
                {
                    server = new TlsServer(IPAddress.Any, DEFAULT_PORT, cert);
                }
            }
            else
            {
                Log.Warning("Not using TLS");
                //insecure version
                server = new TcpServer(IPAddress.Any, DEFAULT_PORT);
            }

            // If we can't start the server, we can't run anything
            if(server == null)
            {
                Log.Error("Could not start the server");
                Environment.Exit(1);
            }

            // All systems go, start the server
            var registry = new Registry();
            var MessageArchive = new MessageArchive();
            var dispatcher = new Dispatcher(server, registry, MessageArchive);
            dispatcher.Run();
        }
예제 #8
0
 public virtual void VisitMessageArchive(MessageArchive messageArchive)
 {
 }