Пример #1
0
//-------------------------------------------------------------------------------------
PyObject* RemoteEntityMethod::tp_call(PyObject* self, PyObject* args, 
	PyObject* kwds)	
{	
	RemoteEntityMethod* rmethod = static_cast<RemoteEntityMethod*>(self);
	MethodDescription* methodDescription = rmethod->getDescription();
	EntityMailboxAbstract* mailbox = rmethod->getMailbox();
	// DEBUG_MSG(boost::format("RemoteEntityMethod::tp_call:%1%.\n") % methodDescription->getName());

	if(methodDescription->checkArgs(args))
	{
		Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
		mailbox->newMail((*pBundle));

		MemoryStream mstream;
		methodDescription->addToStream(&mstream, args);

		if(mstream.wpos() > 0)
			(*pBundle).append(mstream.data(), mstream.wpos());

		mailbox->postMail((*pBundle));
		Mercury::Bundle::ObjPool().reclaimObject(pBundle);
	}
	else
	{
        ERROR_MSG(boost::format("RemoteEntityMethod::tp_call:%1% checkArgs is error!\n") %
                methodDescription->getName());
	}

	S_Return;
}		
Пример #2
0
//-------------------------------------------------------------------------------------
PyObject* RemoteEntityMethod::tp_call(PyObject* self, PyObject* args, 
	PyObject* kwds)	
{	
	RemoteEntityMethod* rmethod = static_cast<RemoteEntityMethod*>(self);
	MethodDescription* methodDescription = rmethod->getDescription();
	EntityMailboxAbstract* mailbox = rmethod->getMailbox();
	// DEBUG_MSG(fmt::format("RemoteEntityMethod::tp_call:{}.\n"), methodDescription->getName()));

	if(methodDescription->checkArgs(args))
	{
		Network::Bundle* pBundle = Network::Bundle::createPoolObject();
		mailbox->newMail((*pBundle));

		MemoryStream mstream;
		methodDescription->addToStream(&mstream, args);

		if(mstream.wpos() > 0)
			(*pBundle).append(mstream.data(), mstream.wpos());

		mailbox->postMail(pBundle);
	}
	else
	{
        ERROR_MSG(fmt::format("RemoteEntityMethod::tp_call:{} checkArgs error!\n",
                methodDescription->getName()));
	}

	S_Return;
}		
Пример #3
0
//-------------------------------------------------------------------------------------
PyObject* BaseRemoteMethod::tp_call(PyObject* self, PyObject* args,
                                    PyObject* kwds)
{
    BaseRemoteMethod* rmethod = static_cast<BaseRemoteMethod*>(self);
    MethodDescription* methodDescription = rmethod->getDescription();
    EntityMailboxAbstract* mailbox = rmethod->getMailbox();

    if(!mailbox->isClient())
    {
        return RemoteEntityMethod::tp_call(self, args, kwds);
    }

    Base* pEntity = Baseapp::getSingleton().findEntity(mailbox->getID());
    if(pEntity == NULL)
    {
        //WARNING_MSG(boost::format("BaseRemoteMethod::callClientMethod: not found entity(%1%).\n") %
        //	mailbox->getID());

        return RemoteEntityMethod::tp_call(self, args, kwds);
    }

    // 如果是调用客户端方法, 我们记录事件并且记录带宽
    if(methodDescription->checkArgs(args))
    {
        Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
        mailbox->newMail((*pBundle));

        MemoryStream* mstream = MemoryStream::ObjPool().createObject();
        methodDescription->addToStream(mstream, args);

        if(mstream->wpos() > 0)
            (*pBundle).append(mstream->data(), mstream->wpos());

        // 记录这个事件产生的数据量大小
        g_privateClientEventHistoryStats.trackEvent(pEntity->getScriptName(),
                methodDescription->getName(),
                pBundle->currMsgLength(),
                "::");

        mailbox->postMail((*pBundle));

        Mercury::Bundle::ObjPool().reclaimObject(pBundle);
        MemoryStream::ObjPool().reclaimObject(mstream);
    }

    S_Return;
}