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);
        }
コード例 #2
0
        // 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);
        }
コード例 #3
0
        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}");
            }
        }
コード例 #4
0
        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}");
            }
        }
コード例 #5
0
        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}");
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
    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);
    }
コード例 #9
0
        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());
        }
コード例 #10
0
 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());
 }
コード例 #11
0
 public void SendWebRequest <T>(string url, HttpRequestBase request, Action <T> callback)
     where T : HttpResponseBase, new()
 {
     _requestSender.SendRequest <T>(url, request, callback);
 }
コード例 #12
0
ファイル: Bus.cs プロジェクト: teyc/Nimbus_v2
 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());
 }