Beispiel #1
0
 private void Start()
 {
     clientEx    = FindObjectOfType <ExampleClient>();
     clientNet   = FindObjectOfType <ClientNetwork>();
     gameManager = FindObjectOfType <GameManager>();
     rb          = GetComponent <Rigidbody>();
 }
Beispiel #2
0
        public async Task TestSubscribe_Doesnt_CrashAsync()
        {
            //var service = new CustomActorService(MockStatefulServiceContextFactory.Default, ActorTypeInformation.Get(typeof(MyStatefulActor)));
            //var factory = new MockActorServiceRemotingClientFactory(service);
            //var proxyFactory = new ActorProxyFactory(callbackClient => factory)

            var guid = Guid.NewGuid();
            var id   = new ActorId(guid);
            Func <ActorService, ActorId, ActorBase> factory = (service, actorId) => new ExampleActorMock(service, actorId);
            var svc   = MockActorServiceFactory.CreateActorServiceForActor <ExampleActorMock>(factory);
            var actor = svc.Activate(id);

            var mockProxyFactory = new MockActorProxyFactory();

            mockProxyFactory.RegisterActor(actor);

            var eventSubscriptionHelper = new MockActorEventSubscriptionHelper();
            var exampleService          = new ExampleClient(MockStatefulServiceContextFactory.Default, new MockReliableStateManager(),
                                                            eventSubscriptionHelper, mockProxyFactory);
            await exampleService.DoSomething(guid, "message text");

            Assert.IsTrue(eventSubscriptionHelper.IsSubscribed <IExampleEvents>(exampleService));
            Assert.IsFalse(IsSuccess);
            //Subscribe doesn't crash the test, but the Event is not really fired and processed at this time
        }
Beispiel #3
0
        /// <summary>
        /// Fired when btnServerConnect is clicked
        /// </summary>
        /// <param name="sender">Object that fired the event</param>
        /// <param name="e">Event arguments</param>
        private void btnServerConnect_Click(object sender, RoutedEventArgs e)
        {
            IPAddress _address;
            int       _port = 0;

            if (IPAddress.TryParse(txtServerIP.Text, out _address))
            {
                if (int.TryParse(txtServerPort.Text, out _port) && 0 < _port && _port < 65536)
                {
                    _client = new ExampleClient(new IPEndPoint(IPAddress.Parse(txtServerIP.Text), Convert.ToInt32(txtServerPort.Text)));
                    btnServerConnect.IsEnabled    = false;
                    btnServerStart.IsEnabled      = false;
                    btnServerDisconnect.IsEnabled = true;

                    txtSend.IsEnabled = true;

                    _client.MessageReceived += _logMessage;
                    _client.MessageSent     += _logMessage;
                    _client.Disconnected    += _clientDisconnected;
                }
                else
                {
                    MessageBox.Show("Please enter a valid port");
                }
            }
            else
            {
                MessageBox.Show("Please enter a valid IP address");
            }
        }
        public async Task Alternative_TestSubscribe_Doesnt_CrashAsync()
        {
            var guid    = Guid.NewGuid();
            var service = new CustomActorService(MockStatefulServiceContextFactory.Default, ActorTypeInformation.Get(typeof(MyStatefulActor)));
            var factory = new MockActorServiceRemotingClientFactory(service);

            var mockProxyFactory = new ActorProxyFactory(callbackClient => factory);
            var exampleService   = new ExampleClient(MockStatefulServiceContextFactory.Default, new MockReliableStateManager(),
                                                     null, mockProxyFactory);
            await exampleService.DoSomething(guid, "message text");

            Assert.IsFalse(IsSuccess);             //Subscribe doesn't crash the test, but the Event is not really fired and processed at this time
        }
Beispiel #5
0
 private void Start()
 {
     client  = FindObjectOfType <ExampleClient>();
     manager = FindObjectOfType <GameManager>();
     if (client.clientNet.IsConnected())
     {
         this.gameObject.SetActive(false);
     }
     if (manager.gameState == GameManager.GameState.endgame)
     {
         titleScreen.SetActive(false);
         manager.gameState = GameManager.GameState.pregame;
     }
 }
Beispiel #6
0
        /// <summary>
        /// Runs whenever the local client disconnects
        /// </summary>
        /// <param name="sender">Object that fired the event</param>
        /// <param name="e">Arguments associated with client disconnects</param>
        private void _clientDisconnected(object sender, DisconnectArgs e)
        {
            _client = null;

            if (_server == null)
            {
                btnServerStart.IsEnabled = true;
            }
            btnServerConnect.IsEnabled    = true;
            btnServerDisconnect.IsEnabled = false;

            txtSend.Text = "";
            txtSend_ChangeTextWithKeyboardFocus(); //See _sendMessage for details
            txtSend.IsEnabled = false;
        }
Beispiel #7
0
 // Use this for initialization
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     // Make sure we have a ClientNetwork to use
     if (clientNet == null)
     {
         clientNet = GetComponent <ClientNetwork>();
     }
     if (clientNet == null)
     {
         clientNet = (ClientNetwork)gameObject.AddComponent(typeof(ClientNetwork));
     }
 }
Beispiel #8
0
        static void Main(string[] args)
        {
            Console.WriteLine("DeltaX.Rpc.JsonRpc.Mqtt.FunctionalTest Started!");

            Configuration.SetDefaultLogger();

            var server = RunRpcServer();
            var client = new ExampleClient();

            Task.WaitAll(server, client.RunAsync());


            DateTime now = DateTime.Now;

            now.ToOADate();
        }
Beispiel #9
0
        public async void ServerClientConnectionInitialization()
        {
            using (var server = new ExampleServer())
                using (var client = new ExampleClient())
                {
                    server.Start();
                    await Task.Delay(500);

                    Assert.True(server.IsRunning);

                    client.Connect();
                    await Task.Delay(500);

                    Assert.True(client.IsConnected);

                    while (true)
                    {
                        Thread.Sleep(1);
                    }
                }
        }
Beispiel #10
0
        public async Task DoSomethingWithAClient()
        {
            _mockProviderService.Given("A Test").UponReceiving("Some State").With(new ContractRequest()
            {
                Url    = "/data",
                Method = "GET"
            }).WillRespondWith(new ContractResponse()
            {
                StatusCode = HttpStatusCode.OK,
                Body       = new List <ExampleData> {
                    new ExampleData {
                        Color = "blue", Id = "5"
                    }
                }
            });
            var client   = new ExampleClient(_factory);
            var response = await client.GetSomethingFromApi();

            Assert.That(response.Count() == 1);
            Assert.That(response.First().Color == "blue");
        }
        public void TestClientServerWithCustomFormat()
        {
            ExampleHttpServer server = new ExampleHttpServer(new ExampleSearchImpl());

            //Setup our custom mime-type format as the only format supported:
            server.Options.MimeInputTypes.Clear();
            server.Options.MimeInputTypes.Add("foo/bar", CodedInputStream.CreateInstance);
            server.Options.MimeOutputTypes.Clear();
            server.Options.MimeOutputTypes.Add("foo/bar", CodedOutputStream.CreateInstance);

            //obviously if this was a 'real' transport we would not use the server, rather the server would be listening, the client transmitting
            IHttpTransfer wire = server;

            ExampleClient exclient = new ExampleClient(wire, "foo/bar");

            //Add our custom mime-type format
            exclient.Options.MimeInputTypes.Add("foo/bar", CodedInputStream.CreateInstance);
            exclient.Options.MimeOutputTypes.Add("foo/bar", CodedOutputStream.CreateInstance);
            ISearchService client = new SearchService(exclient);

            //now the client has a real, typed, interface to work with:
            SearchResponse result = client.Search(SearchRequest.CreateBuilder().AddCriteria("Test").Build());

            Assert.AreEqual(1, result.ResultsCount);
            Assert.AreEqual("Test", result.ResultsList[0].Name);
            Assert.AreEqual("http://search.com", result.ResultsList[0].Url);

            //The test part of this, call the only other method
            result =
                client.RefineSearch(
                    RefineSearchRequest.CreateBuilder().SetPreviousResults(result).AddCriteria("Refine").Build());
            Assert.AreEqual(2, result.ResultsCount);
            Assert.AreEqual("Test", result.ResultsList[0].Name);
            Assert.AreEqual("http://search.com", result.ResultsList[0].Url);

            Assert.AreEqual("Refine", result.ResultsList[1].Name);
            Assert.AreEqual("http://refine.com", result.ResultsList[1].Url);
        }
    void Start()
    {
        client = new ExampleClient();

        client.Connect(host, port);
    }