Inheritance: 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
ファイル: Dispatcher.cs プロジェクト: rit-sse-mycroft/core
 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
ファイル: Reply.cs プロジェクト: rit-sse-mycroft/core
 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
ファイル: Query.cs プロジェクト: rit-sse-mycroft/core
 /// <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
ファイル: Broadcast.cs プロジェクト: rit-sse-mycroft/core
        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
ファイル: Program.cs プロジェクト: rit-sse-mycroft/core
        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
ファイル: Command.cs プロジェクト: rit-sse-mycroft/core
 public virtual void VisitMessageArchive(MessageArchive messageArchive)
 {
 }