예제 #1
0
        public void SendMessage(string message)
        {
            ValidateNotDisposed();

            SignalingClient.SendMessage(_handle, message).
            ThrowIfFailed("Failed to send message to peer");
        }
예제 #2
0
        public void RequestSession(int peerId)
        {
            ValidateNotDisposed();

            SignalingClient.RequestSession(_handle, peerId).
            ThrowIfFailed("Failed to request session to peer");
        }
예제 #3
0
 public void Relay(RelayMessage message)
 {
     if (_signalingClient == null)
     {
         _signalingClient = _container.Resolve<SignalingClient>();
     }
     _signalingClient.Relay(message);
 }
예제 #4
0
        public int GetID()
        {
            ValidateNotDisposed();

            if (!IsConnected)
            {
                throw new InvalidOperationException("Client is not connected to server yet.");
            }

            SignalingClient.GetID(_handle, out int id).
            ThrowIfFailed("Failed to get signaling client ID");

            return(id);
        }
예제 #5
0
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed || !disposing)
            {
                return;
            }

            if (_handle != null)
            {
                SignalingClient.Disconnect(_handle);

                _isConnected = false;
                _disposed    = true;
            }
        }
예제 #6
0
        public WebRTCSignalingClient(string serverIp, int port)
        {
            IntPtr zero = IntPtr.Zero;

            ValidationUtil.ValidateIsNullOrEmpty(serverIp, nameof(serverIp));

            _signalingMessageCallback = (type, message, _) =>
            {
                Log.Info(WebRTCLog.Tag, $"type:{type}, message:{message}");

                if (type == SignalingMessageType.Connected)
                {
                    _isConnected = true;
                }

                SignalingMessage?.Invoke(this, new WebRTCSignalingEventArgs(type, message));
            };

            SignalingClient.Connect(serverIp, port, _signalingMessageCallback, zero, out _handle).
            ThrowIfFailed("Failed to connect to server");
        }
예제 #7
0
        public ConnectionStatus ConnectToSignalingServer(ConnectionOwner connectionOwner)
        {
            SignaledPeerData.Reset();
            SignalingStatus.Reset();
            SignaledRelayMessages.Reset();
            _streamSocket = new StreamSocket();
            _streamSocket.ConnectAsync(new HostName(SignalingSettings.SignalingServerHost),
                                       SignalingSettings.SignalingServerPort, SocketProtectionLevel.PlainSocket)
            .AsTask()
            .Wait();

            _isConnected = true;

            _signalingClient = _unityContainer.Resolve <SignalingClient>();

            StartReading();

            return(new ConnectionStatus
            {
                IsConnected = _isConnected
            });
        }
예제 #8
0
 public void Relay(RelayMessage message)
 {
     SignalingClient.Relay(message);
 }
예제 #9
0
 public async Task Relay(RelayMessage message)
 {
     await SignalingClient.RelayAsync(message);
 }
예제 #10
0
 public ClientChannel(SignalingClient signalingClient)
 {
     _signalingClient = signalingClient;
 }