public StartMatchmakingResponse JoinMatchmakingQueue(Game game, GameMode mode, int msTimeout = 10000) { var req = new StartMatchmakingRequest(game.Id, mode.Name, game.Name, game.Version, mode.PlayerCount, typeof(MatchmakingCog).Assembly.GetName().Version, _client.Config.MatchamkingBotUser.JidUser); var mut = new AutoResetEvent(false); using (var mess = new Messanger()) { mess.OnResetXmpp(_xmpp); StartMatchmakingResponse resp = null; mess.Map <StartMatchmakingResponse>(x => { if (x.RequestId == req.RequestId) { resp = x; } mut.Set(); }); mess.Send(req); if (!mut.WaitOne(msTimeout)) { return(null); } return(resp); } }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { StartMatchmakingResponse response = new StartMatchmakingResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("MatchmakingTicket", targetDepth)) { var unmarshaller = MatchmakingTicketUnmarshaller.Instance; response.MatchmakingTicket = unmarshaller.Unmarshall(context); continue; } } return(response); }