git-svn-id: svn://elaine/murooma/trunk@253 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
(no author) 2014-09-11 21:42:12 +00:00
parent 8039c3d023
commit 25f7f3060d
19 changed files with 26 additions and 1660 deletions

View file

@ -2,13 +2,14 @@
StreamSession::StreamSession(socket_ptr sock) : active_(false), socket_(sock)
StreamSession::StreamSession(std::shared_ptr<tcp::socket> _socket) : ServerConnection(NULL, _socket)
{
}
void StreamSession::sender()
void StreamSession::worker()
{
active_ = true;
try
{
boost::asio::streambuf streambuf;
@ -16,8 +17,7 @@ void StreamSession::sender()
for (;;)
{
shared_ptr<BaseMessage> message(messages.pop());
message->serialize(stream);
boost::asio::write(*socket_, streambuf);
ServerConnection::send(message.get());
}
}
catch (std::exception& e)
@ -25,29 +25,21 @@ void StreamSession::sender()
std::cerr << "Exception in thread: " << e.what() << "\n";
active_ = false;
}
active_ = false;
}
void StreamSession::start()
{
active_ = true;
senderThread = new thread(&StreamSession::sender, this);
// readerThread.join();
}
void StreamSession::send(shared_ptr<BaseMessage> message)
{
if (!message)
return;
while (messages.size() > 100)//* chunk->getDuration() > 10000)
while (messages.size() > 100)// chunk->getDuration() > 10000)
messages.pop();
messages.push(message);
}
bool StreamSession::isActive() const
{
return active_;
}