Esempio n. 1
0
        public MainPage()
        {
            InitializeComponent();

            Dispatcher.BeginInvoke(() =>
            {
                StartButton.IsEnabled = false;
                StopButton.IsEnabled  = false;
            });


            // need to set up the serializer to be used by stream listeners
            StreamingClientFactory.SetSerializer(new Serializer());

            // build an rpc client and log it in.
            rpcClient = new Client(new Uri(StaticTestConfig.RpcUrl), new Uri(StaticTestConfig.StreamingUrl), StaticTestConfig.AppKey);

            rpcClient.StartMetrics();
            // get a session from the rpc client
            rpcClient.BeginLogIn(StaticTestConfig.ApiUsername, StaticTestConfig.ApiPassword, ar =>
            {
                rpcClient.EndLogIn(ar);

                rpcClient.MagicNumberResolver.PreloadMagicNumbersAsync();

                Debug.WriteLine("creating client");

                // build a streaming client.
                _streamingClient = StreamingClientFactory.CreateStreamingClient(new Uri(StaticTestConfig.StreamingUrl), StaticTestConfig.ApiUsername, rpcClient.Session);

                Debug.WriteLine("connecting client");

                // note: due to internal changes the 'connect' method
                // name is a misnomer: no actual network activity is occuring,
                // only the building of the necessary client connections for
                // each of the published data adapters. Actual connection is
                // performed on demand for each adapter. This minimizes startup time.

                // the upside to this is that there is no need to run .Connect in a separate thread.



                Debug.WriteLine("client connected");


                // from this point there should be no need to stop, disconnect or dispose of the
                // client instance. But if you choose to disconnect a StreamingClient, it should
                // be disposed and reinstantiated. it is a one use object at this point as this is
                // the only usage pattern presented in the sample code.

                Dispatcher.BeginInvoke(() =>
                {
                    listBox1.Items.Add("logged in");


                    StartButton.IsEnabled = true;
                    StopButton.IsEnabled  = false;
                });
            }, null);
        }
Esempio n. 2
0
 static RpcFixtureBase()
 {
     LogManager.CreateInnerLogger = (logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat)
                                    => new SimpleDebugAppender(logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat);
     // need to set up the serializer to be used by stream listeners
     StreamingClientFactory.SetSerializer(new Serializer());
 }
Esempio n. 3
0
        public void InitializeStreamingClient(ReliableAsyncResult ar)
        {
            RpcClient.EndLogIn(ar);
            // need to set up the serializer to be used by stream listeners
            StreamingClientFactory.SetSerializer(new Serializer());

            StreamingClient = StreamingClientFactory.CreateStreamingClient(STREAMING_URI, RpcClient.UserName,
                                                                           RpcClient.Session);
            LogToScreen("rpc client logged in");
        }