Example #1
0
 public async Task <ILightningInvoiceListener> Listen(CancellationToken cancellation = default(CancellationToken))
 {
     return(new EclairSession(
                await WebsocketHelper.CreateClientWebSocket(_address.AbsoluteUri,
                                                            new AuthenticationHeaderValue("Basic",
                                                                                          Convert.ToBase64String(Encoding.Default.GetBytes($":{_password}"))).ToString(), cancellation), this));
 }
Example #2
0
        public async Task CollectPickups()
        {
            using (var u = new WebsocketHelper())
            {
                // connect to game

                await u.Connect(TestConfig.WS);


                // check this is the unium project running

                dynamic about = await u.Get("/about");

                Assert.AreEqual("gwaredd", (string)about.Company);
                Assert.AreEqual("unium", (string)about.Product);
                Assert.AreEqual("Tutorial", (string)about.Scene);


                // reload the tutorial scene (ensures we are in the start state)

                dynamic scene = await u.Get("/utils/scene/Tutorial");

                Assert.IsNotNull(scene.scene);
                Assert.AreEqual("Tutorial", (string)scene.scene);


                // get positions of all pickups

                dynamic pickups = await u.Get("/q/scene/Game/Pickup.transform.position");

                Assert.IsNotNull(pickups.Count == 4);

                // collect pickups

                await u.Bind("/scene/Game.Tutorial.OnPickupCollected");

                foreach (JToken pickup in pickups)
                {
                    var pos = pickup.ToString(Formatting.None);

                    await u.Get($"/q/scene/Game/Player.Player.MoveTo({pos})");

                    await u.WaitFor("OnPickupCollected", 10.0f);
                }


                // check there are no more pickups left in the level

                dynamic pickupsLeft = await u.Get("/q/scene/Game/Pickup.name");

                Assert.IsNotNull(pickupsLeft.Count == 0);


                // diconnect

                await u.Disconnect();
            }
        }
Example #3
0
 public async Task <ChargeSession> Listen(CancellationToken cancellation = default(CancellationToken))
 {
     return(new ChargeSession(
                await WebsocketHelper.CreateClientWebSocket(Uri.ToString(),
                                                            $"Basic {ChargeAuthentication.GetBase64Creds()}", cancellation)));
 }
 public async Task <ILightningInvoiceListener> Listen(CancellationToken cancellation = default(CancellationToken))
 {
     return(new PtarmiganSession(
                await WebsocketHelper.CreateClientWebSocket(_address.ToString(), "Bearer " + _apiToken, cancellation), _network, this));
 }
Example #5
0
 public static string GetWebsocketAuthorizationHeader(HttpRequest request)
 {
     return(WebsocketHelper.GetCustomHeader(request, "authorization"));
 }
Example #6
0
 /// <summary>
 ///
 /// </summary>
 private void StopWebSocketServer()
 {
     WebsocketHelper.Stop();
 }
Example #7
0
 /// <summary>
 ///
 /// </summary>
 private void InitWebSocketServer(int port)
 {
     WebsocketHelper.Start(port);
 }