Beispiel #1
0
        public async Task AddPlayerAsync(int gameId, int playerId)
        {
            using (var adminService = new AdminServiceClient(new BasicHttpBinding(), new EndpointAddress(ConnectionData.Url)))
            {
                int sequenceNumber = SequenceNumber;

                var addGamePlayerReq = new AddGamePlayerReq
                {
                    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,
                    PlayerId = playerId,
                };

                _stopwatch.Start();

                var addGamePlayerResp = await adminService.AddGamePlayerAsync(addGamePlayerReq);

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

                if (addGamePlayerResp.Status != "OK")
                {
                    throw new Exception(addGamePlayerResp.Message);
                }
            }
        }
 private void AddGamePlayerImpl(AddGamePlayerReq req, AddGamePlayerResp resp)
 {
     Server.GameManager.AddGamePlayer(req.GameId, req.PlayerId, Server.TeamRegistry.GetTeam(req.Auth.TeamName));
 }
 public AddGamePlayerResp AddGamePlayer(AddGamePlayerReq req)
 {
     return(HandleServiceCall(req, new AddGamePlayerResp(), AddGamePlayerImpl));
 }