コード例 #1
0
void ConsoleRequestHandler::forwardMessages(Poco::Net::WebSocket& webSocket)
{
	_pChannel->messageLogged += Poco::delegate(this, &ConsoleRequestHandler::onMessageLogged);
	
	try
	{
		Poco::AutoPtr<Poco::Notification> pNf = _queue.waitDequeueNotification();
		while (pNf)
		{
			Poco::AutoPtr<MessageNotification> pMessageNf = pNf.cast<MessageNotification>();
			if (pNf)
			{
				std::string json(messageToJSON(pMessageNf->message()));
				webSocket.sendFrame(json.data(), static_cast<int>(json.size()));				
				pNf = _queue.waitDequeueNotification();
			}
			// break if StopNotification
		}
	}
	catch (Poco::Exception&)
	{
	}
	
	_pChannel->messageLogged -= Poco::delegate(this, &ConsoleRequestHandler::onMessageLogged);
}
コード例 #2
0
ファイル: httpwstest.cpp プロジェクト: pranavk/online
void HTTPWSTest::sendTextFrame(Poco::Net::WebSocket& socket, const std::string& string)
{
    socket.sendFrame(string.data(), string.size());
}