Starts Mycroft's network communications and owns resources in the server
Inheritance: ICommandable
Ejemplo n.º 1
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();
 }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
 public virtual void VisitServer(TcpServer server)
 {
 }