Exemplo n.º 1
0
        public async Task <IActionResult> Modify(string name, string live, string record, [Optional] string[] push_urls)
        {
            RtmpApplications UpdatedApp = new RtmpApplications
            {
                name      = name,
                live      = live,
                record    = record,
                push_urls = push_urls
            };

            await FirebaseInteractions.UpdateApplication(UpdatedApp, _fireBaseToken);

            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 2
0
        public static async Task <bool> RemoveApplication(RtmpApplications app, string Token)
        {
            FirebaseClient firebase = new FirebaseClient(firebaseRootUrl, new FirebaseOptions {
                AuthTokenAsyncFactory = () => Task.FromResult(Token)
            });
            var applications = firebase.Child($"applications/{app.name}");

            try
            {
                await applications.DeleteAsync();
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        public static async Task <bool> UpdateApplication(RtmpApplications app, string Token)
        {
            FirebaseClient firebase = new FirebaseClient(firebaseRootUrl, new FirebaseOptions {
                AuthTokenAsyncFactory = () => Task.FromResult(Token)
            });
            var applications = firebase.Child($"applications/{app.name}");

            try
            {
                app.name = null;
                string json = JsonConvert.SerializeObject(app);
                await applications.PutAsync(json);
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        public static async Task <RtmpApplications> GetApplicationByIdAsync(string Id, string Token)
        {
            FirebaseClient firebase = new FirebaseClient(firebaseRootUrl, new FirebaseOptions {
                AuthTokenAsyncFactory = () => Task.FromResult(Token)
            });
            var applications = firebase.Child("applications");
            var apps         = await applications.OnceAsync <RtmpApplications>();

            RtmpApplications AppPointer = null;

            foreach (var app in apps)
            {
                if (app.Key == Id)
                {
                    app.Object.name = app.Key;

                    List <string> pushUrls;

                    if (app.Object.push_urls == null)
                    {
                        pushUrls = new List <string>();
                    }
                    else
                    {
                        pushUrls = new List <string>(app.Object.push_urls);
                    }

                    for (int i = pushUrls.Count; i < 5; i++)
                    {
                        pushUrls.Add(string.Empty);
                    }

                    app.Object.push_urls = pushUrls.ToArray();

                    AppPointer = app.Object;
                }
            }

            return(AppPointer);
        }