Esempio n. 1
0
        public async Task SetMapAsync(int gameId, Map map)
        {
            using (var adminService = new AdminServiceClient(new BasicHttpBinding(), new EndpointAddress(ConnectionData.Url)))
            {
                int sequenceNumber = SequenceNumber;

                var setGameMapReq = new SetGameMapReq
                {
                    Auth = new ReqAuth
                    {
                        ClientName     = ConnectionData.Username,
                        TeamName       = ConnectionData.TeamName,
                        SessionId      = _sessionId,
                        SequenceNumber = sequenceNumber,
                        AuthCode       =
                            GetAuthCode(string.Format("{0}:{1}:{2}:{3}{4}", ConnectionData.TeamName, ConnectionData.Username,
                                                      _sessionId, sequenceNumber, ConnectionData.Password)),
                    },
                    GameId  = gameId,
                    MapData = new EnMapData
                    {
                        Height = map.Height,
                        Width  = map.Width,
                        Rows   = map.Rows.ToArray(),
                    }
                };

                _stopwatch.Start();

                var setGameMapResp = await adminService.SetGameMapAsync(setGameMapReq);

                _stopwatch.Stop();
                LastCallTime = _stopwatch.ElapsedMilliseconds;
                _stopwatch.Reset();

                if (setGameMapResp.Status != "OK")
                {
                    throw new Exception(setGameMapResp.Message);
                }
            }
        }
 private void SetGameMapImpl(SetGameMapReq req, SetGameMapResp resp)
 {
     Server.GameManager.SetGameMap(req.GameId, req.MapData.ToMapData(), Server.TeamRegistry.GetTeam(req.Auth.TeamName));
 }
 public SetGameMapResp SetGameMap(SetGameMapReq req)
 {
     return(HandleServiceCall(req, new SetGameMapResp(), SetGameMapImpl));
 }