예제 #1
0
//--------------------------------------------------------------------------
//	功能:与(账号)服务器建立连接
//	状态切换:成功 LL_S_IDLE -> LL_S_WAIT_INPUT_ACCOUNT
//			  失败 状态保持
//--------------------------------------------------------------------------
int KLogin::CreateConnection(const unsigned char* pAddress)
{
	int nRet;
	if (m_Status == LL_S_IDLE && pAddress &&
		ConnectAccountServer(pAddress))
	{
		RegistNetAgent();
		m_Status = LL_S_WAIT_INPUT_ACCOUNT;
		m_Result = LL_R_NOTHING;

		if (m_bInAutoProgress)
		{
			char	szAccount[32];
            KSG_PASSWORD Password;
			GetAccountPassword(szAccount, &Password);
			AccountLogin(szAccount, Password, false);
			memset(szAccount, 0, sizeof(szAccount));
			memset(&Password, 0, sizeof(Password));
		}
		nRet = true;
	}
	else
	{
		if (m_bInAutoProgress)
			m_bInAutoProgress = false;
		m_Result = LL_R_CONNECT_FAILED;
		nRet = false;
	}
	return nRet;
}
예제 #2
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;
}