示例#1
0
        public void TestFindQuest()
        {
            ISessionFactory fac     = RomViewContainer.Container.GetInstance <ISessionFactory>();
            ISession        session = fac.OpenSession();

            //ITransaction tx = session.BeginTransaction();
            CallSessionContext.Bind(session);
            GoalSetter gs = RomViewContainer.Container.GetInstance <GoalSetter>();

            ICharacterRepository charRep = RomViewContainer.Container.GetInstance <ICharacterRepository>();
            CharacterDefinition  toon    = charRep.FindByName("Remedial");

            gs.Character      = toon;
            gs.State          = new CharacterState();
            gs.State.Location = new Vector3(6130, 137, 23169);

            var a = gs.DetermineNearestQuest();

            CallSessionContext.Unbind(fac);
        }
        public string HandleMessage(String oneLine)
        {
            _logger.InfoFormat("HandleMessage: {0}", oneLine);
            ISession session = _factory.OpenSession();

            CallSessionContext.Bind(session);
            ITransaction tx = session.BeginTransaction();

            try
            {
                string response = null;

                //log!!!
                if (oneLine == null)
                {
                    return(null);
                }

                string[] sections = oneLine.Split((char)1);
                if (sections.Length < 2)
                {
                    return(null);
                }

                switch (sections[0])
                {
                case "ITEM":
                    response = _handleItemMessage(sections);
                    break;

                case "QUEST":
                    response = _handleQuestMessage(sections);
                    break;

                case "NPC":
                    response = _handleNPEMessage(sections);
                    break;

                case "TOON":
                    response = _handleToonMessage(sections);
                    break;

                case "MAP":
                    response = _handleMapMessage(sections);
                    break;

                default:
                    //log
                    break;
                }

                tx.Commit();
                if (!string.IsNullOrEmpty(response))
                {
                    response += GetDelimiter();
                }
                return(response);
            } catch (Exception ex)
            {
                tx.Rollback();
                LogManager.GetLogger(typeof(RomMessageProcessor)).Error(ex.ToString());
                return(ex.Message);
            }
            finally
            {
                CallSessionContext.Unbind(_factory);
            }
        }