public override void FoundPeer(MCNearbyServiceBrowser browser, MCPeerID peerID, NSDictionary info)
        {
            System.Console.WriteLine("MCNearbyServiceBrowserDelegate Found peer " + peerID.DisplayName);

            // Initialize dual purpose object status and cache object for PeerID
            if (!AppDelegate.PeerHistoryMonitor.ContainsKey(peerID.DisplayName))
            {
                AppDelegate.PeerHistoryMonitor.Add(peerID.DisplayName, new PeerMonitorStatus()
                {
                    LastActive = DateTime.UtcNow,
                    PeerID     = peerID
                });
            }


            /*
             *
             * // DEBUG ONLY - this IF statement is commented out while only one machine is a browse
             *  .. in the real world, both machines will be Advertiser and browser.
             *
             * // commented out while testing on two different machines (one is dedicated browser, other is dedicated advertiser... see NearbyDevicesViewController.cs)
             *
             *
             */
            // Connect to server if the hash value is greater
            //if (browser.MyPeerID.GetNativeHash() > peerID.GetNativeHash())
            {
                System.Console.WriteLine("browser ID" + browser.MyPeerID.GetNativeHash());
                System.Console.WriteLine("PeerID " + peerID.GetNativeHash());
                browser.InvitePeer(peerID, session, context, 60);
            }
        }
예제 #2
0
        public override void DidReceiveInvitationFromPeer(MCNearbyServiceAdvertiser advertiser, MCPeerID peerID, NSData context, MCNearbyServiceAdvertiserInvitationHandler invitationHandler)
        {
            System.Diagnostics.Debug.WriteLine("Advertiser [" + session.MyPeerID.GetNativeHash() + "] will accept invite from " + peerID.DisplayName + " [" + peerID.GetNativeHash() + "]");

            MyPhoneStatus.LastInvitation = DateTime.UtcNow;

            MyPhoneStatus.ConnectedPeers.Clear();
            MyPhoneStatus.ConnectedPeers.AddRange(session.ConnectedPeers);

            invitationHandler(true, session);
        }