Ejemplo n.º 1
0
    public IEnumerator Add_device_pub_sub_and_get_match_via_poll()
    {
        Matchmore    matchMore = SetupMatchmore();
        var          subDevice = CreateMobileDevice(matchMore, makeMain: true);
        Subscription sub;
        Publication  pub;

        SetupMatch(matchMore, subDevice, out sub, out pub);

        Match match = null;

        for (int i = 10 - 1; i >= 0; i--)
        {
            var matches = matchMore.GetMatches();
            match = matches.Find(m => m.Publication.Id == pub.Id && m.Subscription.Id == sub.Id);
            if (match != null)
            {
                break;
            }
            else
            {
                yield return(new WaitForSeconds(3));
            }
        }

        Assert.IsNotNull(match);
    }
Ejemplo n.º 2
0
    public void Start()
    {
        var config = Matchmore.Config.WithApiKey(apiKey);

        config.UseSecuredCommunication = false;
        Matchmore.Configure(config);
        Matchmore.Instance.WipeData();
    }
Ejemplo n.º 3
0
 public static void Reset()
 {
     if (_instance != null)
     {
         _instance.CleanUp();
         _instance = null;
     }
 }
Ejemplo n.º 4
0
 public static void Configure(Config config)
 {
     if (_instance != null)
     {
         throw new InvalidOperationException("Matchmore static instance already configured");
     }
     _instance = new Matchmore(config);
 }
    public void Throws_on_invalid_key()
    {
        var apiKey = "invalid key";

        Assert.Throws <ArgumentException>(() => Matchmore.Configure(apiKey));

        Assert.Null(Matchmore.Instance);
    }
    public void Configure_static_instance()
    {
        var apiKey = "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJpc3MiOiJhbHBzIiwic3ViIjoiMzU2OGRhMWMtM2YxYS00MzdiLWFiNjYtN2JlNmU4Y2IzODg2IiwiYXVkIjpbIlB1YmxpYyJdLCJuYmYiOjE1MTg1MjEwNzMsImlhdCI6MTUxODUyMTA3MywianRpIjoiMSJ9.Jt4FtCApf5xHxwgmsT1xrZuRK53krIP886TptVn-7QRqZYpwX1RE5svrfUmn1XUcuVxWum-qwDIi_BvoVmykyg";

        Matchmore.Configure(Matchmore.Config.WithApiKey(apiKey));
        Assert.NotNull(Matchmore.Instance);
        Assert.AreEqual("https://" + Matchmore.PRODUCTION + "/v5", Matchmore.Instance.ApiUrl);
    }
Ejemplo n.º 7
0
    private static Device CreateMobileDevice(Matchmore matchMore, bool makeMain = false)
    {
        Device mobileDevice = matchMore.CreateDevice(new MobileDevice
        {
            Name        = "Mobile",
            DeviceToken = ""
        }, makeMain);

        Assert.NotNull(mobileDevice);
        Assert.NotNull(mobileDevice.Id);
        Assert.AreEqual(mobileDevice.Id, matchMore.MainDevice.Id);
        return(mobileDevice);
    }
Ejemplo n.º 8
0
    private static void SetupMatch(Matchmore matchMore, Device subDevice, out Subscription sub, out Publication pub)
    {
        var pubDevice = matchMore.CreateDevice(new MobileDevice
        {
            Name = "Publisher"
        });


        Assert.NotNull(pubDevice);
        Assert.NotNull(pubDevice.Id);

        sub = matchMore.CreateSubscription(new Subscription
        {
            Topic    = "Unity",
            Duration = 30,
            Range    = 100,
            Selector = "test = true and price <= 200",
            Pushers  = new List <string>()
            {
                "ws"
            }
        }, subDevice);
        Assert.NotNull(sub);
        Assert.NotNull(sub.Id);

        pub = matchMore.CreatePublication(new Publication
        {
            Topic      = "Unity",
            Duration   = 30,
            Range      = 100,
            Properties = new Dictionary <string, object>()
            {
                { "test", true },
                { "price", 199 }
            }
        }, pubDevice);
        Assert.NotNull(pub);
        Assert.NotNull(pub.Id);

        matchMore.UpdateLocation(new Location
        {
            Latitude  = 54.414662,
            Longitude = 18.625498
        }, subDevice);

        matchMore.UpdateLocation(new Location
        {
            Latitude  = 54.414662,
            Longitude = 18.625498
        }, pubDevice);
    }
Ejemplo n.º 9
0
 public WebsocketMatchMonitor(Matchmore client, Device deviceToSubscribe, string worldId)
 {
     _client            = client;
     _deviceToSubscribe = deviceToSubscribe;
     _worldId           = worldId;
 }
Ejemplo n.º 10
0
 public PollingMatchMonitor(Matchmore client, Device deviceToSubscribe)
 {
     _client            = client;
     _deviceToSubscribe = deviceToSubscribe;
 }
Ejemplo n.º 11
0
 public AuxiliaryMatchMonitor(Matchmore client, Device deviceToSubscribe)
 {
     _client            = client;
     _deviceToSubscribe = deviceToSubscribe;
 }
 public void Reset()
 {
     Matchmore.Reset();
 }