public async Task <Guid> CreateRoom(int serverId, Guid roomId, Dictionary <byte, object> properties, Dictionary <Guid, Dictionary <byte, object> > players) { var response = await _requestSender.SendRequest <CreateRoomResponse>("", new CreateRoomRequest(properties, players)); return(response.RoomId); }
// private string GetUrl(int gameServerId) // { // var server = _gameServerList[gameServerId]; // if (server == null) // throw new Exception($"GetUrl error: there is no game server with id = {gameServerId}"); // // return UrlHelper.GetUrl(server.HttpPort, server.HttpsPort, server.Address); // } public async Task <Guid> CreateRoom(string gameServerUrl, Guid roomId, Dictionary <byte, object> properties, Dictionary <Guid, Dictionary <byte, object> > players) { var response = await _requestSender.SendRequest <CreateRoomResponse>(gameServerUrl, new CreateRoomRequest(properties, players) { RoomId = roomId }); if (!response.Success) { var msg = $"CreateRoom error: {response.Message}"; _logger.Error(msg); throw new Exception(msg); } return(response.RoomId); }
public async Task UpdateRoomState(Guid roomId, int roomPlayersCount, RoomState roomState, string matchMakerUrl, int maxMatchMakingWeight) { try { if (string.IsNullOrWhiteSpace(matchMakerUrl)) { _logger.Error($"SendRoomStateUpdate error: matchmaker URL is empty in properties container"); return; } await _requestSender.SendRequest <UpdateRoomStateResponse>(matchMakerUrl, new UpdateRoomStateRequest(roomId, roomPlayersCount, roomState, maxMatchMakingWeight), (r) => { if (!r.Success) { _logger.Error($"Room update error: {r.Message}"); } else { _logger.Debug($"Room update to {matchMakerUrl} with players count {roomPlayersCount}, state {roomState} successful"); } }); } catch (Exception e) { _logger.Error($"Update room state error: {e}"); } }
public async Task Actualize(int peersCount) { var response = await _requestSender.SendRequest <ActualizeServerOnRouterResponse>(_routingConfig.RouterUrl, new ActualizeServerOnRouterRequest(_routingConfig.Identity, _routingConfig.ServerName, _routingConfig.Region, peersCount, _routingConfig.HttpPort, _routingConfig.HttpsPort)); if (!response.Success) { _logger.Error($"MatchMakerServerInfoProvider.ActualizeMe error: {response.Message}"); } }
public async Task Actualize(int peersCount) { var request = new ActualizeServerOnMatchMakerRequest(_config.GetIdentity(), _config.ServerName, _config.Region, _statsProvider.GetPeerCount(), _config.BindToPortHttp, 0); var response = await _requestSender.SendRequest <ActualizeServerOnMatchMakerResponse>(_matchMakerInfoProvider.MatchMakerUrl, request); if (!response.Success) { _logger.Error($"GameToMmServerActualizer error: {response.Message}"); } }
private async Task <string> GetBundleUriImpl() { var serverIdentity = GetServerIdentity(); var response = await _requestSender.SendRequest <GetBundleUriResponse>(_config.RouterUrl, new GetBundleUriRequest(serverIdentity)); if (!response.Success) { throw new BundleNotFoundException($"Bundle not found for: {serverIdentity}, requested from '{_config.RouterUrl}': {response.Message}"); } _logger.Error($"Bundle uri received for '{serverIdentity}' (overwrite = {_config.OverwriteBundle}): {response.BundleUri}"); return(response.BundleUri); }
public async Task <EntityDictionary <ServerInfo> > GetServerInfoList(bool actualOnly) { var response = await _requestSender.SendRequest <GetServerInfoListResponse>(_routingConfig.RouterUrl, new GetServerInfoListRequest(actualOnly)); if (response.ResultCode != ResultCode.OK) { _logger.Error( $"BackendProvider error: error getting backends {response.ResultCode}|{response.Message}"); _emptyList = new EntityDictionary <ServerInfo>(); return(_emptyList); } return(response.ServerInfoList); }
public ICompletes <Response> RequestWith(Request request, ICompletes <Response> completes) { _completesEventually = Stage.World.CompletesFor(completes); if (_testId != EmptyTestId) { request.Headers.Add(RequestHeader.Of(Client.ClientIdCustomHeader, _testId)); request.Headers.Add(RequestHeader.Of(RequestHeader.XCorrelationID, _testId)); } _requestSender.SendRequest(request); StowMessages(typeof(IResponseChannelConsumer)); return(completes); }
public async Task <IActionResult> Index([FromForm] string url, [FromServices] IRequestSender requestSender) { var request = new HttpRequestMessage(); request.RequestUri = new Uri(url); request.Method = HttpMethod.Get; try { HttpResponseMessage response = await requestSender.SendRequest(request); ViewBag.Message = $"La richiesta si è conclusa con lo status code: {response.StatusCode}"; } catch (Exception exc) { ViewBag.Message = $"La richiesta ha prodotto un errore: {exc.Message}"; } ViewBag.Url = url; return(View()); }
public Task <TResponse> Request <TRequest, TResponse>(IBusRequest <TRequest, TResponse> busRequest) where TRequest : IBusRequest <TRequest, TResponse> where TResponse : IBusResponse { return(Task.Run(() => _requestSender.SendRequest(busRequest)).ConfigureAwaitFalse()); }
public void SendWebRequest <T>(string url, HttpRequestBase request, Action <T> callback) where T : HttpResponseBase, new() { _requestSender.SendRequest <T>(url, request, callback); }
public Task <TResponse> Request <TRequest, TResponse>(IBusRequest <TRequest, TResponse> busRequest) where TRequest : IBusRequest <TRequest, TResponse> where TResponse : IBusResponse { return(_taskFactory.StartNew(() => _requestSender.SendRequest(busRequest), TaskContext.Send).Unwrap()); }