Пример #1
0
        /// <summary>
        /// Executes the command.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="requestInfo">The request info.</param>
        public override void ExecuteCommand(TWebSocketSession session, SubRequestInfo requestInfo)
        {
            if (string.IsNullOrEmpty(requestInfo.Body))
            {
                ExecuteJsonCommand(session, default(TJsonCommandInfo));
                return;
            }

            TJsonCommandInfo jsonCommandInfo;

            if (!string.IsNullOrEmpty(requestInfo.Token))
            {
                session.CurrentToken = requestInfo.Token;
            }

            if (!m_IsSimpleType)
            {
                jsonCommandInfo = (TJsonCommandInfo)session.AppServer.JsonDeserialize(requestInfo.Body, m_CommandInfoType);
            }
            else
            {
                jsonCommandInfo = (TJsonCommandInfo)Convert.ChangeType(requestInfo.Body, m_CommandInfoType);
            }

            ExecuteJsonCommand(session, jsonCommandInfo);
        }
Пример #2
0
        /// <summary>
        /// Executes the command.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="requestInfo">The request info.</param>
        public override void ExecuteCommand(TWebSocketSession session, SubRequestInfo requestInfo)
        {
            if (string.IsNullOrEmpty(requestInfo.Body))
            {
                ExecuteJsonCommand(session, default(TJsonCommandInfo));
                return;
            }

            TJsonCommandInfo jsonCommandInfo;

            LocalDataStoreSlot tokenSlot = null;

            if (!string.IsNullOrEmpty(requestInfo.Token))
            {
                tokenSlot = session.SetCurrentToken(requestInfo.Token);
            }

            try
            {
                if (!m_IsSimpleType)
                {
                    jsonCommandInfo = (TJsonCommandInfo)session.AppServer.JsonDeserialize(requestInfo.Body, m_CommandInfoType);
                }
                else
                {
                    jsonCommandInfo = (TJsonCommandInfo)Convert.ChangeType(requestInfo.Body, m_CommandInfoType);
                }

                ExecuteJsonCommand(session, jsonCommandInfo);
            }
            finally
            {
                if (tokenSlot != null)
                {
                    Thread.SetData(tokenSlot, null);
                }
            }
        }