示例#1
0
        private static SizeQueue <JObject> m_messageQueue = new SizeQueue <JObject>(2); // no more than one message for now

        public static int Init(string[] args, fMain f)
        {
            // configure log4net
            log4net.Config.XmlConfigurator.Configure();

            log.Info("application started");
            log.DebugFormat("command line : \"{0}\"", string.Join("\", \"", args));

            // started with no arguments?
            if (args.Length == 0)
            {
                Usage();
            }

            // started by chrome?
            else if (args[args.Length - 1].StartsWith("chrome-extension://"))
            {
                RunNativeMessagingHost(args, f);
            }

            // register command?
            else if (args[args.Length - 1] == "register")
            {
                RegisterNativeMessagingHost(args);
            }

            // invalid command line
            else
            {
                InvalidCommand(args[args.Length - 1]);
            }

            log.Info("application stopped");
            return(0);
        }
示例#2
0
 /// <summary>
 /// Creates a new instance of native messaging host.
 /// </summary>
 public Host(fMain f, SizeQueue <JObject> messageQueue)
 {
     port           = new Port();
     stop           = new ManualResetEvent(false);
     m_f            = f;
     m_messageQueue = messageQueue;
 }
示例#3
0
        static int RunNativeMessagingHost(string[] args, fMain f)
        {

            Host host = new Host(f, m_messageQueue);
            Thread workerThread = new Thread(host.Run);
            workerThread.Start();
            return 0;
        }
示例#4
0
        static int RunNativeMessagingHost(string[] args, fMain f)
        {
            Host   host         = new Host(f, m_messageQueue);
            Thread workerThread = new Thread(host.Run);

            workerThread.Start();
            return(0);
        }
示例#5
0
        private static SizeQueue<JObject> m_messageQueue = new SizeQueue<JObject>(2); // no more than one message for now

        public static int Init(string[] args, fMain f)
        {
            // configure log4net
            log4net.Config.XmlConfigurator.Configure();

            log.Info("application started");
            log.DebugFormat("command line : \"{0}\"", string.Join("\", \"", args));

            // started with no arguments?
            if (args.Length == 0) Usage();

            // started by chrome?
            else if (args[args.Length - 1].StartsWith("chrome-extension://")) RunNativeMessagingHost(args, f);

            // register command?
            else if (args[args.Length - 1] == "register") RegisterNativeMessagingHost(args);

            // invalid command line
            else InvalidCommand(args[args.Length - 1]);

            log.Info("application stopped");
            return 0;
        }