예제 #1
0
        private void DisposeSocket()
        {
            if (this.peerConnectionSocket == null)
            {
                return;
            }

            this.peerConnectionSocket.ErrorRaisedEvent   -= this.PeerConnectionSocketErrorRaisedEvent;
            this.peerConnectionSocket.MessageRaisedEvent -= this.PeerConnectionSocketMessageRaisedEvent;
            this.peerConnectionSocket.Dispose();
            this.peerConnectionSocket = null;
            this.RouteToUiThread(
                () =>
            {
                this.ConnectedPeer = null;
                this.SendMessage.OnCanExecuteChanged();
            });
        }
예제 #2
0
        private void InitializeSocket(StreamSocket socket)
        {
            if (this.peerConnectionSocket != null)
            {
                this.DisposeSocket();
            }

            try
            {
                this.peerConnectionSocket = new PeerSocket(socket);
                this.peerConnectionSocket.ErrorRaisedEvent   += this.PeerConnectionSocketErrorRaisedEvent;
                this.peerConnectionSocket.MessageRaisedEvent += this.PeerConnectionSocketMessageRaisedEvent;
                this.RouteToUiThread(() => this.SendMessage.OnCanExecuteChanged());
                this.peerConnectionSocket.ReadLoop();
            }
            catch (Exception ex)
            {
                this.RouteToUiThread(() => this.ErrorMessage = ex.Message);
            }
        }