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(); }); }
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); } }