void Start() { if (this.PairingRole == Role.Connector) { this.pairMaker = new DirectPairConnector(this.RemoteAddress, this.RemotePort); } else { this.pairMaker = new DirectPairReceiver(this.LocalPort); } this.pairingAdapter = new PairingAdapter(); this.pairingAdapter.SuccessEvent += OnPairingConnectionSucceeded; this.pairingAdapter.FailureEvent += OnPairingConnectionFailed; // Register to listen for disconnections, so we can reconnect automatically if (SharingStage.Instance != null) { this.sharingMgr = SharingStage.Instance.Manager; if (this.sharingMgr != null) { this.connectionAdapter = new NetworkConnectionAdapter(); this.connectionAdapter.DisconnectedCallback += OnDisconnected; NetworkConnection pairedConnection = this.sharingMgr.GetPairedConnection(); pairedConnection.AddListener((byte)MessageID.StatusOnly, this.connectionAdapter); } } StartPairing(); }