コード例 #1
0
ファイル: ViewModel.cs プロジェクト: msdiniz/WinRTExamples
        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
ファイル: ViewModel.cs プロジェクト: msdiniz/WinRTExamples
        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);
            }
        }