public void FoundPeer(MCNearbyServiceBrowser browser, MCPeerID peerID, NSDictionary info) { if (peerID != this.myself.PeerId) { var appIdentifier = info?[XamarinShotGameAttribute.AppIdentifier]; if (appIdentifier?.ToString() == NSBundle.MainBundle.BundleIdentifier) { DispatchQueue.MainQueue.DispatchAsync(() => { var player = new Player(peerID); var gameName = info?[XamarinShotGameAttribute.Name] as NSString; GameTableLocation location = null; var locationIdString = info?[XamarinShotGameAttribute.Location] as NSString; if (!string.IsNullOrEmpty(locationIdString) && int.TryParse(locationIdString, out int locationId)) { location = GameTableLocation.GetLocation(locationId); } var game = new NetworkGame(player, gameName, location?.Identifier ?? 0); this.games.Add(game); this.Delegate?.SawGames(this, new List <NetworkGame>(this.games)); }); } } }
public NetworkSession Join(NetworkGame game) { NetworkSession result = null; if (this.games.Contains(game)) { result = new NetworkSession(this.myself, false, game.Location, game.Host); this.serviceBrowser.InvitePeer(game.Host.PeerId, result.Session, null, 30d); } return(result); }