Example #1
0
bool CExtraProcessor::ProcessCommand(void)
{
    try {
        if( Operation == Operation_GetServerInfo ) {
            GetServerInfo();
            return(true);
        }
        if( Operation == Operation_ShutdownServer ) {
            ShutdownServer();
            return(true);
        }
        if( Operation == Operation_GetServerErrors ) {
            GetServerErrors();
            return(true);
        }
        if( Operation == Operation_RegisterClient ) {
            RegisterClient();
            return(true);
        }
        if( Operation == Operation_UnregisterClient ) {
            UnregisterClient();
            return(true);
        }
    } catch(std::exception& e) {
        CMD_ERROR_FROM_EXCEPTION(Command,"unable process the request",e);
        return(false);
    }

    CSmallString error;
    error << "operation " << Operation.GetStringForm() << " is not implemented";
    CMD_ERROR(Command,error);

    return(false);
}
Example #2
0
/**
  Function : CreateTestStepL
  Description : This method creates the startup and shut down test steps
  @return : A pointer to the CTestStep class
*/
CTestStep* CT_MsgServer::CreateTestStepL(const TDesC& aStepName)
	{
	CTestStep*	testStep = NULL;

	/* This must be called as the first test step */
	if(aStepName == KStartUp)					
		{
		StartupServerL();
		testStep = new(ELeave) CT_MsgStartUp();
		}
	/* This must be called as the last test step */
	else if(aStepName == KShutDown)				
		{
		ShutdownServer();
		testStep = new(ELeave) CT_MsgShutDown();
		}
	else if(aStepName == KRecordCurrentTime)
		{
		testStep = new(ELeave) CT_MsgRecordCurrentTime();	
		}

	else
		{
		ERR_PRINTF1(_L("CT_MsgServer::CreateTestStep() - Step not found"));	
		}
	return testStep;
	}
Example #3
0
boost::statechart::result QuittingGame::react(const StartQuittingGame& u) {
    TraceLogger(FSM) << "(HumanClientFSM) QuittingGame";

    m_server_process = &u.m_server;
    m_after_server_shutdown_action = u.m_after_server_shutdown_action;

    post_event(ShutdownServer());
    return discard_event();
}
Example #4
0
boost::statechart::result QuittingGame::react(const StartQuittingGame& u) {
    TraceLogger(FSM) << "(HumanClientFSM) QuittingGame reset to intro is " << u.m_reset_to_intro;

    m_reset_to_intro = u.m_reset_to_intro;
    m_server_process = &u.m_server;

    post_event(ShutdownServer());
    return discard_event();
}
Example #5
0
    int CTimerdWorld::FromRpcCall(CPluto& u)
    {
        pluto_msgid_t msg_id = u.GetMsgId();
        if(!CheckClientRpc(u))
        {
            LogWarning("from_rpc_call", "invalid rpcall error.unknown msgid:%d\n", msg_id);
            return -1;
        }

        T_VECTOR_OBJECT* p = m_rpc.Decode(u);
        if(p == NULL)
        {
            LogWarning("from_rpc_call", "rpc decode error.unknown msgid:%d\n", msg_id);
            return -1;
        }
        if(u.GetDecodeErrIdx() > 0)
        {
            ClearTListObject(p);
            LogWarning("from_rpc_call", "rpc decode error.msgid:%d;pluto err idx=%d\n", msg_id, u.GetDecodeErrIdx());
            return -2;
        }

        int nRet = -1;
        switch(msg_id)
        {
            case MSGID_ALLAPP_SHUTDOWN_SERVER:
            {
                nRet = ShutdownServer(p);
                break;
            }
            default:
            {
                LogWarning("from_rpc_call", "unknown msgid:%d\n", msg_id);
            }
        }

        if(nRet != 0)
        {
            LogWarning("from_rpc_call", "rpc error.msg_id=%d;ret=%d\n", msg_id, nRet);
        }

        ClearTListObject(p);

        return 0;
    }
Example #6
0
 static bool HandleServerIdleRestartCommand(ChatHandler* handler, char const* args)
 {
     return ShutdownServer(handler, args, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, RESTART_EXIT_CODE);
 }
Example #7
0
 static bool HandleServerIdleShutDownCommand(ChatHandler* handler, char const* args)
 {
     return ShutdownServer(handler, args, SHUTDOWN_MASK_IDLE, SHUTDOWN_EXIT_CODE);
 }
Example #8
0
    int CWorldDbmgr::FromRpcCall(CPluto& u, CDbOper& db)
    {
        //printf("CWorldDbmgr::from_rpc_call\n");
        //print_hex_pluto(u);

        pluto_msgid_t msg_id = -1;
        T_VECTOR_OBJECT* p = NULL;

        //这一段要加锁(2012/02/15改为不加锁)
        {
            //CMutexGuard _g(m_rpcMutex);

            msg_id = u.GetMsgId();
            if(!CheckClientRpc(u))
            {
                LogWarning("from_rpc_call", "invalid rpcall error.unknown msgid:%d\n", msg_id);
                return -1;
            }

            p = m_rpc.Decode(u);
            if(p == NULL)
            {
                LogWarning("from_rpc_call", "rpc Decode error.unknown msgid:%d\n", msg_id);
                return -1;
            }

            if(u.GetDecodeErrIdx() > 0)
            {
                ClearTListObject(p);
                //PrintHexPluto(u);
                LogWarning("from_rpc_call", "rpc Decode error.msgid:%d;pluto err idx=%d\n", msg_id, u.GetDecodeErrIdx());
                return -2;
            }
        }

        //这一段不用加锁
        int nRet = -1;
        switch(msg_id)
        {
            case MSGID_DBMGR_INSERT_ENTITY:
            {
                nRet = InsertDB(p, db);
                break;
            }
            case MSGID_DBMGR_SELECT_ENTITY:
            {
                nRet = LookupEntityByDbId(p, db);
                break;
            }
            case MSGID_DBMGR_UPDATE_ENTITY:
            {
                nRet = UpdateEntity(p, db);
                break;
            }
            case MSGID_DBMGR_UPDATE_ENTITY_REDIS:
            {
                nRet = UpdateEntityToRedis(p, db);
                break;
            }
            case MSGID_DBMGR_SELECT_ACCOUNT:
            {
                nRet = SelectAccount(p, db);
                break;
            }
            case MSGID_DBMGR_RAW_MODIFY_NORESP:
            {
                nRet = QueryModifyNoResp(p, db);
                break;
            }
            case MSGID_DBMGR_CREATEBASE_FROM_NAME:
            {
                nRet = LookupEntityByName(p, db);
                break;
            }
            case MSGID_DBMGR_LOAD_ALL_AVATAR:
            {
                nRet = LoadAllAvatars(p, db);
                break;
            }
            case MSGID_DBMGR_LOAD_ENTITIES_OF_TYPE:
            {
                nRet = LoadEntitiesOfType(p, db);
                break;
            }
            case MSGID_DBMGR_SHUTDOWN_SERVER:
            {
                nRet = ShutdownServer(p);
                break;
            }
            case MSGID_DBMGR_REDIS_HASH_LOAD:
            {
                nRet = RedisHashLoad(p, db);
                break;
            }
            case MSGID_DBMGR_REDIS_HASH_SET:
            {
                nRet = RedisHashSet(p, db);
                break;
            }
            case MSGID_DBMGR_REDIS_HASH_DEL:
            {
                nRet = RedisHashDel(p, db);
                break;
            }
            case MSGID_DBMGR_DEL_ACCOUNT_CACHE:
            {
                nRet = DestroyAccountCache(p);
                break;
            }

            case MSGID_DBMGR_UPDATE_ITEMS:
            {
                nRet = UpdateArrayItemsToDb(p, db);
                break;
            }
            case MSGID_DBMGR_LOADING_ITEMS:
            {
                nRet = LoadingArrayItemsToInventory(p, db);
                break;
            }
            case MSGID_DBMGR_INCREMENTAL_UPDATE_ITEMS:
            {
                nRet = IncremantalUpdateItems(p, db);
                break;
            }

            case MSGID_DBMGR_TABLE_SELECT:
            {
                nRet = TableSelect(p, db);
                break;
            }
            case MSGID_DBMGR_UPDATE_BATCH:
            {
                nRet = TableUpdateBatch(p, db);
                break;
            }
            case MSGID_DBMGR_TABLE_INSERT:
            {
                nRet = TableInsert(p, db);
                break;
            }
            case MSGID_DBMGR_TABLE_EXCUTE:
            {
                nRet = TableExcute(p, db);
                break;
            }
            case MSGID_DBMGR_TABLE2_SELECT:
            {
                nRet = Table2Select(p, db);
                break;
            }
            case MSGID_DBMGR_TABLE2_INSERT:
            {
                nRet = Table2Insert(p, db);
                break;
            }
            case MSGID_DBMGR_TABLE2_EXCUTE:
            {
                nRet = Table2Excute(p, db);
                break;
            }
            default:
            {
                break;
            }
        }

        if(nRet != 0)
        {
            LogWarning("from_rpc_call", "rpc error.msg_id=%d;ret=%d\n", msg_id, nRet);
        }

        ClearTListObject(p);

        return 0;
    }
Example #9
0
 static bool HandleServerRestartCommand(ChatHandler* /*handler*/, char const* args)
 {
     return ShutdownServer(args, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE);
 }
Example #10
0
 static bool HandleServerShutDownCommand(ChatHandler* /*handler*/, char const* args)
 {
     return ShutdownServer(args, 0, SHUTDOWN_EXIT_CODE);
 }
Example #11
0
SocketClass :: ~SocketClass()
{
	ShutdownServer();
}
Example #12
0
//in parent class , this method has a pure virtual access limited
int CWorldLogin::FromRpcCall(CPluto& u)
{
    //printf("CWorldLogin::from_rpc_call\n");
    //printf("handle pluto in FromRpcCall()! : start!\n");
	pluto_msgid_t msg_id = u.GetMsgId();
    //printf("message id : %d\n", msg_id);
	if(!CheckClientRpc(u))
	{
		LogWarning("FromRpcCall", "invalid rpcall error.unknown msgid:%d\n", msg_id);
		return -1;
	}

	T_VECTOR_OBJECT* p = m_rpc.Decode(u);
	if(p == NULL)
	{
		LogWarning("FromRpcCall", "rpc decode error.unknown msgid:%d\n", msg_id);
		return -1;
	}

	if(u.GetDecodeErrIdx() > 0)
	{
		ClearTListObject(p);
		LogWarning("FromRpcCall", "rpc decode error.msgid:%d;pluto err idx=%d\n", msg_id, u.GetDecodeErrIdx());
		return -2;
	}
    printf("MSGID_LOGINAPP_MODIFY_LOGIN_FLAG:%d\n", MSGID_LOGINAPP_MODIFY_LOGIN_FLAG);
    int nRet = -1;
    switch(msg_id)
    {
        case MSGID_LOGINAPP_LOGIN:
        {
            AddClientFdToVObjectList(u.GetMailbox()->GetFd(), p);
            nRet = AccountLogin(p);
            break;
        }
        case MSGID_LOGINAPP_SELECT_ACCOUNT_CALLBACK:
        {
            nRet = SelectAccountCallback(p);
            break;
        }
        case MSGID_LOGINAPP_NOTIFY_CLIENT_TO_ATTACH:
        {
            nRet = NotifyClientToAttach(p);
            break;
        }
	    case MSGID_LOGINAPP_MODIFY_LOGIN_FLAG:  
		{
			nRet = ModifyLoginFlag(p);
			break;
		}
	    case MSGID_ALLAPP_SHUTDOWN_SERVER://103
		{
			nRet = ShutdownServer(p);
			break;
		}
        default:
        {
            LogWarning("CWorldLogin::from_rpc_call", "unknown msgid:%d\n", msg_id);
            break;
        }
    }

	if(nRet != 0)
	{
		LogWarning("from_rpc_call", "rpc error.msg_id=%d;ret=%d\n", msg_id, nRet);
	}

    ClearTListObject(p);
    //printf("handle pluto in FromRpcCall()! : end!\n");
    return 0;
}
Example #13
0
	int CWorldOther::FromRpcCall(CPluto& u, CDbOper& db)
	{
		//printf("CWorldOther::from_rpc_call\n");
		//print_hex_pluto(u);

		pluto_msgid_t msg_id = -1;
		T_VECTOR_OBJECT* p = NULL;

		//这一段要加锁(2012/02/15改为不加锁)
		{
			//CMutexGuard _g(m_rpcMutex);

			msg_id = u.GetMsgId();
			if(!CheckClientRpc(u))
			{
				LogWarning("from_rpc_call", "invalid rpcall error.unknown msgid:%d\n", msg_id);
				return -1;
			}

			p = m_rpc.Decode(u);
			if(p == NULL)
			{
				LogWarning("from_rpc_call", "rpc Decode error.unknown msgid:%d\n", msg_id);
				return -1;
			}

			if(u.GetDecodeErrIdx() > 0)
			{
				ClearTListObject(p);
				//PrintHexPluto(u);
				LogWarning("from_rpc_call", "rpc Decode error.msgid:%d;pluto err idx=%d\n", msg_id, u.GetDecodeErrIdx());
				return -2;
			}
		}

        //这一段不用加锁
        int nRet = -1;
        switch(msg_id)
        {
            case MSGID_LOG_INSERT:
            {
                nRet = InsertDB(p, db);
                break;
            }
            case MSGID_OTHER_HTTP_REQ:
            {
                nRet = ReqUrl(p);
                break;
            }
            case MSGID_ALLAPP_SHUTDOWN_SERVER:
            {
                nRet = ShutdownServer(p);
                break;
            }
            case MSGID_OTHER_ADD_GLOBALBASE:
            {
                nRet = RegisterGlobally(p);
                break;
            }
            case MSGID_OTHER_YUNYING_API:
            {
                nRet = SupportApi(p, u.GetMailbox(), db);
                break;
            }
            case MSGID_OTHER_CLIENT_RESPONSE:
            {
                nRet = Response2Browser(p);
				PrintHexPluto(u);
                break;
            }
            //case MSGID_OTHER_LOGIN_VERIFY:
            //{
            //    //todo:verify
            //    nRet = SdkServerVerify(p, u);
            //    break;
            //}
// 			case MSGID_OTHER_PLAT_API:
// 			{
// 				nRet = PlatApi(p, u.GetMailbox(), db);
// 				break;
// 			}
            default:
            {
                LogWarning("from_rpc_call", "rpc unkown msg_id = %d\n", msg_id, nRet);
                break;
            }
        }

		if(nRet != 0)
		{
			LogWarning("from_rpc_call", "rpc error.msg_id=%d;ret=%d\n", msg_id, nRet);
		}

		ClearTListObject(p);

		return 0;
	}