Beispiel #1
0
    static async Task test_connect()
    {
        var key     = "live_key";
        var options = new RtmpClient.Options
        {
            // required parameters:
            Url     = $"rtmp://live.twitch.tv/app/{key}",
            Context = new SerializationContext(),

            // optional parameters:
            AppName = "app",                            // optional app name, passed to the remote server during connect.
            //PageUrl = "",                             // optional page url, passed to the remote server during connect.
            //SwfUrl = "",                              // optional swf url, passed to the remote server during connect.
            //FlashVersion = "WIN 21,0,0,174",          // optional flash version, paased to the remote server during connect.

            //ChunkLength = 4192,                       // optional outgoing rtmp chunk length.
            //Validate = (sender, certificate, chain, errors) => true // optional certificate validation callback. used only in tls connections.
        };

        using (var client = await RtmpClient.ConnectAsync(options))
        {
            //var exists = await client.InvokeAsync<bool>("storage", "exists", new { name = "music.pdf" });
            var createStream = await client.Connection.CreateStreamAsync();

            await createStream.PublishAndWaitAsync(key, "live");
        }
    }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="regionData"></param>
        /// <param name="rsoAuthToken"></param>
        /// <param name="partnerCred">Same as AccessToken</param>
        /// <returns></returns>
        public static async Task <RtmpLoginResult> LoginRtmps(RegionData regionData, string rsoAuthToken, string partnerCred, string userName)
        {
            var client      = new RiotCalls();
            var rtmpClasses = HelperFunctions.GetInstances <RiotRtmpObject>();
            var typeList    = new List <Type>();

            foreach (var rtmpClass in rtmpClasses)
            {
                typeList.Add(rtmpClass.GetType());
            }
            var context = new SerializationContext(typeList.ToArray());
            var options = new RtmpClient.Options
            {
                Url         = $"rtmps://{regionData.Servers.Lcds.LcdsHost}:{regionData.Servers.Lcds.LcdsPort}",
                Context     = context,
                Validate    = (sender, certificate, chain, errors) => true,
                AppName     = "LCU",
                PageUrl     = null,
                SwfUrl      = null,
                ChunkLength = 16500
            };

            //Pass to the rtmpclient
            client.RiotConnection = await RtmpClient.ConnectAsync(options);

            client.IsConnectedToRtmp = true;

            var authCred = new AuthenticationCredentials
            {
                MacAddress         = LoginSystemData.MacAddress,
                AuthToken          = rsoAuthToken,
                PartnerCredentials = partnerCred,
                OperatingSystem    = LoginSystemData.OperatingSystem,
                Username           = userName
            };

            var loginResult = await client.Login(authCred);

            if (loginResult.GetType() == typeof(Session))
            {
                client.RegionData  = regionData;
                client.RiotSession = (Session)loginResult;
                return(new RtmpLoginResult(true, client, null));
            }

            if (loginResult.GetType() != typeof(LoginFailedException))
            {
                return(new RtmpLoginResult(false, null, null));
            }

            client.IsConnectedToRtmp = false;
            await client.RiotConnection.CloseAsync();

            return(new RtmpLoginResult(false, null, (LoginFailedException)loginResult));
        }
Beispiel #3
0
        static async Task <RtmpClient> BotClientAsync()
        {
            try
            {
                Console.WriteLine("Client connecting...");
                var options = new RtmpClient.Options
                {
                    Url     = "rtmp://localhost:4000",
                    AppName = "bot",
                };
                var client = await RtmpClient.ConnectAsync(options);

                Console.WriteLine("Client connected.");
                //client.Disconnected += (o, s) => { ((RtmpClient)o).InvokeAsync<object>("FCUnpublish").Wait(); };
                client.DispatchInvoke = s =>
                {
                    switch (s.MethodName)
                    {
                    case "a":
                        var windowName = (string)s.Arguments[0];
                        botHandle = Interop.GetHandleByWindow(windowName ?? "Star Citizen");
                        break;

                    case "k":
                        var key = (char)s.Arguments[0];
                        Interop.PressKey((byte)key);
                        break;

                    case "c":
                        Interop.ClickMouseButton(botHandle, InteropMouseButton.Left, new Point(545, 300));
                        break;

                    case "bf":
                        Interop.BringToFront(botHandle);
                        break;

                    default:
                        Console.WriteLine(s.MethodName);
                        break;
                    }
                };
                return(client);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(null);
            }
        }
Beispiel #4
0
    static async Task test_client_server()
    {
        var serverOptions = new RtmpServer.Options
        {
            Url     = "rtmp://localhost:4000/key",
            Context = new SerializationContext(),
        };

        using (var server = await RtmpServer.ConnectAsync(serverOptions, x => { }))
        {
            var clientOptions = new RtmpClient.Options
            {
                Url     = "rtmp://localhost:4000/key",
                Context = new SerializationContext(),
            };
            using (var client = await RtmpClient.ConnectAsync(clientOptions))
            {
                Console.WriteLine("Connect");
            }
        }
    }