Esempio n. 1
0
        public override void OnClose()
        {
            IEnumerable <IPlayer> validPlayers = LiveCache.GetAll <IPlayer>().Where(player => player.Descriptor != null &&
                                                                                    player.Template <IPlayerTemplate>().Account.Config.WantsNotification(_currentPlayer.AccountHandle, false, AcquaintenceNotifications.LeaveGame));

            foreach (IPlayer player in validPlayers)
            {
                player.WriteTo(new string[] { string.Format("{0} has left the game.", _currentPlayer.AccountHandle) });
            }

            if (_currentPlayer != null && _currentPlayer.Template <IPlayerTemplate>().Account.Config.GossipSubscriber)
            {
                IGossipClient gossipClient = LiveCache.Get <IGossipClient>("GossipWebClient");

                if (gossipClient != null)
                {
                    gossipClient.SendNotification(_currentPlayer.AccountHandle, AcquaintenceNotifications.LeaveGame);
                }
            }

            base.OnClose();
        }
Esempio n. 2
0
        /// <summary>
        /// Validates the game account from the aspnet cookie
        /// </summary>
        /// <param name="handshake">the headers from the http request</param>
        private void ValidateUser(Cookie cookie)
        {
            //Grab the user
            GetUserIDFromCookie(cookie.Value);

            ApplicationUser authedUser = UserManager.FindById(_userId);

            IPlayerTemplate currentCharacter = authedUser.GameAccount.Characters.FirstOrDefault(ch => ch.Id.Equals(authedUser.GameAccount.CurrentlySelectedCharacter));

            if (currentCharacter == null)
            {
                Send("<p>No character selected</p>");
                return;
            }

            //Try to see if they are already live
            _currentPlayer = LiveCache.GetAll <IPlayer>().FirstOrDefault(player => player.Descriptor != null && player.Descriptor._userId == _userId);

            //Check the backup
            if (_currentPlayer == null)
            {
                PlayerData playerDataWrapper = new PlayerData();
                _currentPlayer = playerDataWrapper.RestorePlayer(currentCharacter.AccountHandle, currentCharacter);
            }

            //else new them up
            if (_currentPlayer == null)
            {
                _currentPlayer = new Player(currentCharacter);
            }

            _currentPlayer.Descriptor = this;

            //We need to barf out to the connected client the welcome message. The client will only indicate connection has been established.
            List <string> welcomeMessage = new List <string>
            {
                string.Format("Welcome to alpha phase Under the Eclipse, {0}", currentCharacter.FullName()),
                "Please feel free to LOOK around."
            };

            _currentPlayer.WriteTo(welcomeMessage);

            //Send the look command in
            Interpret.Render("look", _currentPlayer);

            try
            {
                IEnumerable <IPlayer> validPlayers = LiveCache.GetAll <IPlayer>().Where(player => player.Descriptor != null &&
                                                                                        player.Template <IPlayerTemplate>().Account.Config.WantsNotification(_currentPlayer.AccountHandle, false, AcquaintenceNotifications.EnterGame));

                foreach (IPlayer player in validPlayers)
                {
                    player.WriteTo(new string[] { string.Format("{0} has entered the game.", _currentPlayer.AccountHandle) });
                }

                if (authedUser.GameAccount.Config.GossipSubscriber)
                {
                    IGossipClient gossipClient = LiveCache.Get <IGossipClient>("GossipWebClient");

                    if (gossipClient != null)
                    {
                        gossipClient.SendNotification(authedUser.GlobalIdentityHandle, AcquaintenceNotifications.EnterGame);
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex, LogChannels.SocketCommunication);
            }
        }
Esempio n. 3
0
 public GossipBasedEndpointDiscoverer(EventStoreClientConnectivitySettings settings,
                                      IGossipClient gossipClient)
 {
     _gossipClient = gossipClient;
     _settings     = settings;
 }