Ejemplo n.º 1
0
	bool handleFrame(Connection::Ptr pConnection, Frame::Ptr pFrame)
	{
		if (pFrame->type() == Frame::FRAME_TYPE_EVSU || pFrame->type() == Frame::FRAME_TYPE_EVUN)
		{
			Poco::RemotingNG::ORB& orb = Poco::RemotingNG::ORB::instance();
			std::string suri(pFrame->payloadBegin(), pFrame->getPayloadSize());
			Poco::URI dispURI(suri);
			dispURI.setAuthority(_pListener->endPoint());
			dispURI.setFragment("");
			Poco::RemotingNG::EventDispatcher::Ptr pEventDispatcher = orb.findEventDispatcher(dispURI.toString(), Transport::PROTOCOL);
			if (pFrame->type() == Frame::FRAME_TYPE_EVSU)
			{
				Poco::Timestamp expire;
				expire += _pListener->getEventSubscriptionTimeout().totalMicroseconds();
				pEventDispatcher->subscribe(suri, suri, expire);
			}
			else
			{
				pEventDispatcher->unsubscribe(suri);
			}
			pConnection->returnFrame(pFrame);
			return true;
		}
		return false;
	}
Ejemplo n.º 2
0
bool FrameQueue::handleFrame(Connection::Ptr pConnection, Frame::Ptr pFrame)
{
	poco_assert_dbg (pConnection == _pConnection);

	if ((_frameType == 0 || pFrame->type() == _frameType) && pFrame->channel() == _channel)
	{
		{
			Poco::FastMutex::ScopedLock lock(_mutex);
			int rounds = 0;
			while (_queue.size() == MAX_QUEUE_SIZE && rounds < 100)
			{
				Poco::ScopedUnlock<Poco::FastMutex> unlock(_mutex);
				Poco::Thread::sleep(5);
				rounds++;
			}
			if (_queue.size() < MAX_QUEUE_SIZE)
			{
				_queue.push_back(pFrame);
				_sema.set();
				return true;
			}
		}
	}
	return false;
}
Ejemplo n.º 3
0
	bool handleFrame(Connection::Ptr pConnection, Frame::Ptr pFrame)
	{
		if (pFrame->type() == Frame::FRAME_TYPE_REQU && (pFrame->flags() & Frame::FRAME_FLAG_CONT) == 0)
		{
			Poco::SharedPtr<ChannelInputStream> pRequestStream = new ChannelInputStream(pConnection, pFrame->type(), pFrame->channel(), _pListener->getTimeout());
			Poco::SharedPtr<ChannelOutputStream> pReplyStream;
			if ((pFrame->flags() & Frame::FRAME_FLAG_ONEWAY) == 0)
			{
				Poco::UInt16 flags(0);
				if (pFrame->flags() & Frame::FRAME_FLAG_DEFLATE)
					flags |= Frame::FRAME_FLAG_DEFLATE;
				pReplyStream = new ChannelOutputStream(pConnection, Frame::FRAME_TYPE_REPL, pFrame->channel(), flags);
			}
			ServerTransport::Ptr pServerTransport = new ServerTransport(*_pListener, pRequestStream, pReplyStream, (pFrame->flags() & Frame::FRAME_FLAG_DEFLATE) != 0);
			_pListener->connectionManager().threadPool().start(*pServerTransport);
			Poco::Thread::yield();
			pServerTransport->waitReady();
			pRequestStream->rdbuf()->queue()->handleFrame(pConnection, pFrame);
			return true;
		}
		else return false;
	}