private void BuildSimulator(string keyFramePath, string liveDataFile, string username, string password, string authKeyFile, bool createThread)
        {
            //_log.Info("Building live timing simulator...");

            IKeyFrame kf = new Simulator.KeyFrame(keyFramePath);

            IAuthKey ak;

            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                ak = new AuthorizationKey(authKeyFile);
            }
            else
            {
                //  We can still use this in the sim, albeit a bit cheeky :)
                ak = new Protocol.AuthorizationKey(username, password);
            }

            _handler = new MessageDispatcherImpl(this);

            MemoryStream memStream = new MemoryStream(MEMSTREAM_SIZE);

            _runtime = new Runtime.Runtime(memStream, ak, kf, _handler);

            //  Create network component that drives the Runtime with data.
            CreateDriver(liveDataFile, kf, memStream);

            if (createThread)
            {
                //_log.Info("Creating child thread to Run simulator");
                Start();
            }
        }
Esempio n. 2
0
 public void initVideoCaller(MessageDispatcherImpl dispatcher)
 {
     videoCaller = new VideoCaller(dispatcher);
     videoCaller.addCaller(agent);
     dispatcher.RegisterReceiveHandler("acceptCall", new MessageHandlerDelegateWrapper(m => acceptCall()));
     dispatcher.RegisterReceiveHandler("endCall", new MessageHandlerDelegateWrapper(m => endCall()));
     dispatcher.RegisterReceiveHandler("videoCallRejected", new MessageHandlerDelegateWrapper(m => endCall()));
 }
Esempio n. 3
0
        public void StringWithNoJson()
        {
            var l = MessageDispatcherImpl.BreakDownToIndividualStrings("Hello, how are you?")
                    .ToList();

            Assert.AreEqual(1, l.Count);
            Assert.AreEqual("Hello, how are you?", l[0]);
        }
Esempio n. 4
0
        public void StringContainingOneObject()
        {
            var l = MessageDispatcherImpl.BreakDownToIndividualStrings("{\"msg_type\":\"gaze\",\"msg_body\":{\"dir\":\"MidRight\"}}")
                    .ToList();

            Assert.AreEqual(1, l.Count);
            Assert.AreEqual("{\"msg_type\":\"gaze\",\"msg_body\":{\"dir\":\"MidRight\"}}", l[0]);
        }
Esempio n. 5
0
        public void StringContainingLessThanOneObject()
        {
            //note: the missing } at the end of string
            string original = "{\"msg_type\":\"gaze\",\"msg_body\":{\"dir\":\"MidRight\"}";
            var    l        = MessageDispatcherImpl.BreakDownToIndividualStrings(original)
                              .ToList();

            Assert.AreEqual(1, l.Count);
            Assert.AreEqual(original, l[0]);
        }
Esempio n. 6
0
        private void InitTcpListener()
        {
            var listener = new MessageTcpListener();

            var dispatcher = new MessageDispatcherImpl(listener);

            var jsonAdapter = new AgentControlJsonAdapter(Agent, dispatcher);

            InitPluginManager(dispatcher);

            listener.Start();
        }
Esempio n. 7
0
        private void InitPluginManager(MessageDispatcherImpl dispatcher)
        {
            var pluginManager = new PluginManager(this);

            foreach (Plugin plugin in plugins)
            {
                pluginManager.RegisterPlugin(plugin.Name, (IPluginCreator)
                                             Activator.CreateInstance(plugin.Creator, new UIThreadDispatcher(this.Dispatcher), dispatcher));
                Debug.WriteLine("Plugin " + plugin.Name + " registered");
            }

            dispatcher.RegisterReceiveHandler("start_plugin", new MessageHandlerDelegateWrapper(x =>
            {
                var v = x["instance_reuse_mode"] as JValue;

                InstanceReuseMode?mode = null;

                if (v != null)
                {
                    InstanceReuseMode m;
                    if (Enum.TryParse <InstanceReuseMode>(v.ToString(), true, out m))
                    {
                        mode = m;
                    }
                }

                if (mode == null)
                {
                    pluginManager.Start(x["name"].ToString(), x["params"] as JObject);
                }
                else
                {
                    pluginManager.Start(x["name"].ToString(), x["params"] as JObject, (InstanceReuseMode)mode);
                }
            }));
            dispatcher.RegisterReceiveHandler("show_plugin", new MessageHandlerDelegateWrapper(x =>
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    pluginManager.Show(x["name"].ToString());
                }));
            }));
            dispatcher.RegisterReceiveHandler("hide_plugin", new MessageHandlerDelegateWrapper(x =>
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    LayoutPageWithoutPlugin();
                }));
            }));
        }
Esempio n. 8
0
        public void StringContainingTwoObjects()
        {
            var thingsBetweenThem = new[] { "", "  ", "\n", "\r\n" };

            foreach (var d in thingsBetweenThem)
            {
                var l = MessageDispatcherImpl.BreakDownToIndividualStrings(
                    "{\"msg_type\":\"gaze\",\"msg_body\":{\"dir\":\"MidRight\"}}" + d +
                    "{\"msg_type\":\"speech\",\"msg_body\":{\"text\":\"Hello\"}}")
                        .ToList();

                Assert.AreEqual(2, l.Count);
                Assert.AreEqual("{\"msg_type\":\"gaze\",\"msg_body\":{\"dir\":\"MidRight\"}}", l[0]);
                Assert.AreEqual("{\"msg_type\":\"speech\",\"msg_body\":{\"text\":\"Hello\"}}", l[1]);
            }
        }
Esempio n. 9
0
        private void InitRuntime()
        {
            //_log.Info("Connecting to live stream....");
            try
            {
                IAuthKey authKeyService = Login(_username, _password);

                IKeyFrame keyFrameService = new KeyFrame();

                _handler = new MessageDispatcherImpl(this);

                MemoryStream memStream = new MemoryStream(MEMSTREAM_SIZE);

                _runtime = new Runtime.Runtime(memStream, authKeyService, keyFrameService, _handler);

                //  Create network component that drives the Runtime with data.
                CreateDriver(keyFrameService, memStream);
            }
            catch (AuthorizationException)
            {
                DoDispatchMessage(new F1.Messages.Control.AuthorizationProblem());
                Stop(true);
            }
        }
        private void BuildSimulator(string keyFramePath, string liveDataFile, string username, string password, string authKeyFile, bool createThread)
        {
            //_log.Info("Building live timing simulator...");

            IKeyFrame kf = new Simulator.KeyFrame(keyFramePath);

            IAuthKey ak;

            if( string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) )
            {
                ak = new AuthorizationKey(authKeyFile);
            }
            else
            {
                //  We can still use this in the sim, albeit a bit cheeky :)
                ak = new Protocol.AuthorizationKey(username, password);
            }

            _handler = new MessageDispatcherImpl(this);

            MemoryStream memStream = new MemoryStream(MEMSTREAM_SIZE);

            _runtime = new Runtime.Runtime(memStream, ak, kf, _handler);

            //  Create network component that drives the Runtime with data.
            CreateDriver(liveDataFile, kf, memStream);

            if (createThread)
            {
                //_log.Info("Creating child thread to Run simulator");
                Start();
            }
        }
Esempio n. 11
0
        private void InitRuntime()
        {
            //_log.Info("Connecting to live stream....");
            try
            {
                IAuthKey authKeyService = Login(_username, _password);

                IKeyFrame keyFrameService = new KeyFrame();

                _handler = new MessageDispatcherImpl(this);

                MemoryStream memStream = new MemoryStream(MEMSTREAM_SIZE);

                _runtime = new Runtime.Runtime(memStream, authKeyService, keyFrameService, _handler);

                //  Create network component that drives the Runtime with data.
                CreateDriver(keyFrameService, memStream);
            }
            catch (AuthorizationException)
            {
                DoDispatchMessage(new F1.Messages.Control.AuthorizationProblem());
                Stop(true);
            }
        }
 public void SetUp()
 {
     sender     = Mock.Of <IRemoteConnection>();
     dispatcher = new MessageDispatcherImpl(sender);
 }