コード例 #1
0
        private async void CreateWebRtcTransportButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var result = await connection.InvokeAsync <dynamic>("CreateWebRtcTransport", new CreateWebRtcTransportRequest
                {
                    ForceTcp  = false,
                    Consuming = true,
                    Producing = false,
                });

                IntPtr param = Marshal.StringToHGlobalAnsi(result.ToString());

                RtclientLib.CreateSendTransport(param);
                //Marshal.FreeHGlobal(param);
                result = await connection.InvokeAsync <dynamic>("CreateWebRtcTransport", new CreateWebRtcTransportRequest
                {
                    ForceTcp  = false,
                    Consuming = false,
                    Producing = true,
                });

                RtclientLib.CreateRecvTransport(param);
                //RtclientLib.JoinRoom();
            }
            catch (Exception ex)
            {
                messagesList.Items.Add(ex.ToString());
            }
        }
コード例 #2
0
        private async void ProcessPeerHandled(object message)
        {
            try
            {
                var result = await connection.InvokeAsync <dynamic>("EnterRoom", Guid.Empty);

                this.Dispatcher.Invoke(() =>
                {
                    var newMessage = $"{result}";
                    messagesList.Items.Add(newMessage);
                });
                result = await connection.InvokeAsync <dynamic>("GetRouterRtpCapabilities");

                this.Dispatcher.Invoke(() =>
                {
                    var newMessage = $"{result}";
                    messagesList.Items.Add(newMessage);
                });
                //load routertp
                IntPtr param = Marshal.StringToHGlobalUni(result.ToString());
                RtclientLib.LoadRtpCapabilities(param);

                //
                result = await connection.InvokeAsync <dynamic>("CreateWebRtcTransport", new CreateWebRtcTransportRequest
                {
                    ForceTcp  = false,
                    Consuming = false,
                    Producing = true,
                });

                param = Marshal.StringToHGlobalAnsi(result.ToString());
                RtclientLib.CreateSendTransport(param);

                //connectwebrtctransport

                //Marshal.FreeHGlobal(param);
                result = await connection.InvokeAsync <dynamic>("CreateWebRtcTransport", new CreateWebRtcTransportRequest
                {
                    ForceTcp  = false,
                    Consuming = true,
                    Producing = false,
                });

                param = Marshal.StringToHGlobalAnsi(result.ToString());
                RtclientLib.CreateRecvTransport(param);
                RtclientLib.JoinRoom(new WindowInteropHelper(this).Handle);
            }
            catch (Exception ex)
            {
                messagesList.Items.Add(ex.ToString());
            }
        }