//-------------------------------------------------------------------------------------
bool EntityMailboxAbstract::postMail(Mercury::Bundle& bundle)
{
	KBE_ASSERT(Components::getSingleton().pNetworkInterface() != NULL);
	Mercury::Channel* pChannel = getChannel();

	if(pChannel && !pChannel->isDead())
	{
		bundle.send(*Components::getSingleton().pNetworkInterface(), pChannel);
		return true;
	}
	else
	{
		ERROR_MSG("EntityMailboxAbstract::postMail: invalid channel(%s)!\n", addr_.c_str());
	}

	return false;
}
Exemple #2
0
//-------------------------------------------------------------------------------------
Proxy::~Proxy()
{
	Baseapp::getSingleton().decProxicesCount();

	// 如果被销毁频道仍然存活则将其关闭
	Mercury::Channel* pChannel = Baseapp::getSingleton().networkInterface().findChannel(addr_);
	if(pChannel && !pChannel->isDead())
	{
		Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
		(*pBundle).newMessage(ClientInterface::onKicked);
		ClientInterface::onKickedArgs1::staticAddToBundle(*pBundle, SERVER_ERR_PROXY_DESTROYED);
		//pBundle->send(Baseapp::getSingleton().networkInterface(), pChannel);
		//Mercury::Bundle::ObjPool().reclaimObject(pBundle);
		this->sendToClient(ClientInterface::onKicked, pBundle);
		this->sendToClient();
		pChannel->condemn();
	}

	SAFE_RELEASE(pProxyForwarder_);
}