void OnMatchmakeMatched(INMatchmakeMatched matchInfo)
    {
        // token to join match
        matchToken = matchInfo.Token;
        matchId    = matchInfo.Token.Token;

        // and join the match found immediately
        JoinMatchByMatchToken(matchToken);
    }
예제 #2
0
        public void MatchmakeRemove()
        {
            ManualResetEvent   evt   = new ManualResetEvent(false);
            INError            error = null;
            INMatchmakeMatched res1  = null;
            INMatchmakeMatched res2  = null;

            client1.OnMatchmakeMatched = (INMatchmakeMatched matched) =>
            {
                res1 = matched;
                evt.Set();
            };
            client2.OnMatchmakeMatched = (INMatchmakeMatched matched) =>
            {
                res2 = matched;
                evt.Set();
            };

            client1.Send(NMatchmakeAddMessage.Default(2), (INMatchmakeTicket ticket1) =>
            {
                client1.Send(NMatchmakeRemoveMessage.Default(ticket1), (bool done) =>
                {
                    client2.Send(NMatchmakeAddMessage.Default(2), (INMatchmakeTicket ticket2) =>
                    {
                        // No action.
                    }, (INError err) =>
                    {
                        error = err;
                    });
                }, (INError err) =>
                {
                    error = err;
                });
            }, (INError err) =>
            {
                error = err;
            });

            evt.WaitOne(2000, false);
            Assert.IsNull(error);
            Assert.IsNull(res1);
            Assert.IsNull(res2);
        }
예제 #3
0
        public void MatchmakeAdd()
        {
            ManualResetEvent   evt   = new ManualResetEvent(false);
            INError            error = null;
            INMatchmakeMatched res   = null;

            client1.OnMatchmakeMatched = (INMatchmakeMatched matched) =>
            {
                res = matched;
                evt.Set();
            };

            client1.Send(NMatchmakeAddMessage.Default(2), (INMatchmakeTicket ticket1) =>
            {
            }, (INError err) =>
            {
                error = err;
            });

            evt.WaitOne(2000, false);
            Assert.IsNull(error);
            Assert.IsNull(res);
        }
예제 #4
0
        public void MatchmakingJoin()
        {
            ManualResetEvent   evt1   = new ManualResetEvent(false);
            ManualResetEvent   evt2   = new ManualResetEvent(false);
            INError            error  = null;
            INError            error1 = null;
            INError            error2 = null;
            INMatchmakeMatched res1   = null;
            INMatchmakeMatched res2   = null;

            client1.OnMatchmakeMatched = (INMatchmakeMatched matched) =>
            {
                res1 = matched;
                evt1.Set();
            };
            client2.OnMatchmakeMatched = (INMatchmakeMatched matched) =>
            {
                res2 = matched;
                evt2.Set();
            };

            client1.Send(NMatchmakeAddMessage.Default(2), (INMatchmakeTicket ticket1) =>
            {
                client2.Send(NMatchmakeAddMessage.Default(2), (INMatchmakeTicket ticket2) =>
                {
                    // No action.
                }, (INError err) =>
                {
                    error = err;
                });
            }, (INError err) =>
            {
                error = err;
            });

            evt1.WaitOne(5000, false);
            evt2.WaitOne(5000, false);
            Assert.IsNull(error);
            Assert.IsNull(error1);
            Assert.IsNull(error2);
            Assert.AreEqual(res1.Token.Token, res2.Token.Token);

            ManualResetEvent evt1m   = new ManualResetEvent(false);
            ManualResetEvent evt2m   = new ManualResetEvent(false);
            INMatch          m1      = null;
            INMatch          m2      = null;
            INError          error1m = null;
            INError          error2m = null;

            client1.Send(NMatchJoinMessage.Default(res1.Token), (INResultSet <INMatch> matches) =>
            {
                m1 = matches.Results[0];
                evt1m.Set();
            }, (INError err) =>
            {
                error1m = err;
                evt1m.Set();
            });
            client2.Send(NMatchJoinMessage.Default(res2.Token), (INResultSet <INMatch> matches) =>
            {
                m2 = matches.Results[0];
                evt2m.Set();
            }, (INError err) =>
            {
                error2m = err;
                evt2m.Set();
            });
            evt1m.WaitOne(5000, false);
            Assert.IsNull(error1m);
            Assert.IsNull(error2m);
            Assert.IsNotNull(m1);
            Assert.IsNotNull(m2);
            Assert.AreEqual(m1.Id, m2.Id);
        }
예제 #5
0
        public void MatchmakeMatched()
        {
            ManualResetEvent   evt1   = new ManualResetEvent(false);
            ManualResetEvent   evt2   = new ManualResetEvent(false);
            INError            error  = null;
            INError            error1 = null;
            INError            error2 = null;
            INMatchmakeMatched res1   = null;
            INMatchmakeMatched res2   = null;

            client1.OnMatchmakeMatched = (INMatchmakeMatched matched) =>
            {
                res1 = matched;
                evt1.Set();
            };
            client2.OnMatchmakeMatched = (INMatchmakeMatched matched) =>
            {
                res2 = matched;
                evt2.Set();
            };



            var b1 = new NMatchmakeAddMessage.Builder(2);

            b1.AddProperty("rank", 12);
            b1.AddProperty("modes", new HashSet <string> {
                "tdm", "ffa"
            });
            b1.AddProperty("divisions", new HashSet <string> {
                "silver1"
            });
            b1.AddRangeFilter("rank", 10, 15);
            b1.AddTermFilter("modes", new HashSet <string> {
                "tdm", "ffa"
            }, false);
            b1.AddTermFilter("divisions", new HashSet <string> {
                "bronze3", "silver1", "silver2"
            }, false);                                                                                 // like RocketLeague
            client1.Send(b1.Build(), (INMatchmakeTicket ticket1) =>
            {
                var b2 = new NMatchmakeAddMessage.Builder(2);
                b2.AddProperty("rank", 10);
                b2.AddProperty("modes", new HashSet <string> {
                    "tdm", "ffa"
                });
                b2.AddProperty("divisions", new HashSet <string> {
                    "bronze3"
                });
                b2.AddRangeFilter("rank", 8, 12);
                b2.AddTermFilter("modes", new HashSet <string> {
                    "tdm", "ffa"
                }, false);
                b2.AddTermFilter("divisions", new HashSet <string> {
                    "bronze2", "bronze3", "silver1"
                }, false);
                client2.Send(b2.Build(), (INMatchmakeTicket ticket2) =>
                {
                    // No action.
                }, (INError err) =>
                {
                    error = err;
                });
            }, (INError err) =>
            {
                error = err;
            });

            evt1.WaitOne(5000, false);
            evt2.WaitOne(5000, false);
            Assert.IsNull(error);
            Assert.IsNull(error1);
            Assert.IsNull(error2);
            Assert.IsNotNull(res1);
            Assert.IsNotNull(res2);
            Assert.IsNotNull(res1.Token);
            Assert.IsNotNull(res2.Token);
            Assert.AreEqual(res1.Token.Token, res2.Token.Token);

            var c1Props = res1.UserProperties[0];

            if (res1.Self.UserId != res1.UserProperties[0].Id)
            {
                c1Props = res1.UserProperties[1];
            }

            Assert.AreEqual(((long)c1Props.Properties["rank"]), 12);
            Assert.AreEqual(((INMatchmakeRangeFilter)c1Props.Filters["rank"]).Lowerbound, 10);
        }