Ejemplo n.º 1
0
        public Wp7ConnectionDriver(Runtime.Runtime runtime, MemoryStream memStream)
            : base(false)
        {
            try
            {
                _memStream = memStream;
                _runtime = runtime;

                _runtime.Driver = this;

                _incoming = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                SocketAsyncEventArgs args = new SocketAsyncEventArgs();
                args.Completed += new EventHandler<SocketAsyncEventArgs>(OnConnected);
                args.RemoteEndPoint = new DnsEndPoint(HOST, PORT);

                if (!_incoming.ConnectAsync(args))
                {
                    OnConnected(null, args);
                }
            }
            catch (SocketException e)
            {
                throw new ConnectionException(e);
            }
        }
        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();
            }
        }
 public void Dispose()
 {
     Stop(JoinMethod.Join, false);
     _connection.Dispose();
     _connection = null;
     _runtime    = null;
 }
Ejemplo n.º 4
0
        public KeyFrameDriver(IKeyFrame provider, Runtime.Runtime runtime)
            : base(false)
        {
            _runtime = runtime;
            _runtime.Driver = this;
            _provider = provider;

            Start();
        }
Ejemplo n.º 5
0
        public W8ConnectionDriver(Runtime.Runtime runtime, MemoryStream memStream)
            : base(false)
        {
            _memStream = memStream;
            _runtime = runtime;

            _runtime.Driver = this;

            _socket = new StreamSocket();
            _socket.ConnectAsync(new HostName(HOST), PORT.ToString()).AsTask().Wait();
            OnConnected();
        }
Ejemplo n.º 6
0
        //private readonly ILog _log = LogManager.GetLogger("FileCapDriver");
        public FileCapDriver(string capFile, MemoryStream memStream, Runtime.Runtime runtime)
            : base(false)
        {
            _memStream = memStream;
            #if WINRT
            _path = capFile;
            #else
            _fileStream = File.OpenRead(capFile);
            #endif
            _runtime = runtime;
            _runtime.Driver = this;

            Start();
        }
Ejemplo n.º 7
0
        public void TestRuntime()
        {
            Stream liveStream = File.OpenRead(LIVEDUMP);
            IAuthKey authKey = new F1.Simulator.AuthorizationKey(DECRYPT_KEY);
            IKeyFrame keyFrame = new F1.Simulator.KeyFrame(KEYFRAMEPATH);

            Runtime r = new Runtime(liveStream, authKey, keyFrame, new NullMessageDispatcher())
                            {
                                Driver = new NullDriver()
                            };

            while(r.HandleRead())
            {

            }
        }
        public AsyncConnectionDriver(Runtime.Runtime runtime, MemoryStream memStream)
            : base(false)
        {
            try
            {
                _memStream = memStream;
                _runtime = runtime;

                _runtime.Driver = this;

                IPHostEntry e = Dns.GetHostEntry(HOST);

                _incoming = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                _log.InfoFormat("Resolved {0} to {1}.", HOST, e.AddressList[0].ToString());

                _log.Info("Connecting...");

            #if COMPACT
                EndPoint ep = new IPEndPoint(e.AddressList[0], PORT);
                _incoming.Connect(ep);
                _incoming.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 10000);
            #else
                _incoming.Connect(e.AddressList, PORT);
                _incoming.ReceiveTimeout = 10000; // 10 seconds because we may not always be receiving data
            #endif

                //  Queue the first read and write
                CmdQueue.Push(CommandFactory.MakeCommand(DoNextRead, new byte[BLOB_SIZE]));
                CmdQueue.Push(CommandFactory.MakeCommand(DoPing));

                Start();

                //  We've sent the first request so schedule timer to start one interval later
                _timer = new Timer(TimerPingCallback, null, _refreshRate, _refreshRate);

                _log.Info("Connected.");

            }
            catch (SocketException e)
            {
                throw new ConnectionException(e);
            }
        }
Ejemplo 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);
            }
        }
Ejemplo n.º 10
0
        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();
            }
        }
Ejemplo n.º 11
0
 public void Dispose()
 {
     Stop(JoinMethod.Join, false);
     _connection.Dispose();
     _connection = null;
     _runtime = null;
 }
Ejemplo n.º 12
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);
            }
        }