[DEBUG] correct the future multiple packet element and some other hiden error

This commit is contained in:
Edouard DUPIN 2016-07-01 23:41:23 +02:00
parent bae883a836
commit 42ada729aa
6 changed files with 26 additions and 19 deletions

View File

@ -62,9 +62,13 @@ void zeus::Buffer::appendBufferData(const ememory::SharedPtr<zeus::Buffer>& _obj
return;
}
if (_obj->getType() != zeus::Buffer::typeMessage::data) {
ZEUS_ERROR("try to add data with a wrong buffer: " << _obj->getType());
ZEUS_ERROR("try to add data with a wrong buffer: " << _obj->getType() << " ==> set the buffer finish ...");
// close the connection ...
setPartFinish(true);
// TODO : Add an error ...
return;
}
setPartFinish(_obj->getPartFinish());
if (_obj->m_parameter.size() <= 1) {
// normal end frame with no data ==> no problem ...
return;
@ -137,8 +141,6 @@ bool zeus::Buffer::writeOn(enet::WebSocket& _interface) {
size += sizeof(uint32_t); // parameter size
size += it.second.size();
}
ZEUS_VERBOSE("Send BINARY " << size << " bytes '" << *this << "'");
if (_interface.writeHeader(size, false) == false) {
return false;
}
@ -249,7 +251,8 @@ uint16_t zeus::Buffer::getPartId() const {
}
void zeus::Buffer::setPartId(uint16_t _value) {
if (getType() != zeus::Buffer::typeMessage::data) {
if ( getType() != zeus::Buffer::typeMessage::data
&& _value != 0) {
ZEUS_ERROR("can not set a partId at other than data buffer");
return;
}

View File

@ -324,9 +324,9 @@ namespace zeus {
ememory::SharedPtr<zeus::Buffer> answer = zeus::Buffer::create();
answer->setTransactionId(_transactionId);
answer->setClientId(_clientId);
answer->setType(zeus::Buffer::typeMessage::data);
answer->setPartId(_partId);
answer->setPartFinish(false);
answer->setType(zeus::Buffer::typeMessage::data);
int32_t tmpSize = ZEUS_MINIMUM_SIZE_MULTIPLE;
if (m_size < ZEUS_MINIMUM_SIZE_MULTIPLE) {
tmpSize = m_size;
@ -396,9 +396,9 @@ namespace zeus {
ememory::SharedPtr<zeus::Buffer> answer = zeus::Buffer::create();
answer->setTransactionId(_transactionId);
answer->setClientId(_clientId);
answer->setType(zeus::Buffer::typeMessage::data);
answer->setPartId(_partId);
answer->setPartFinish(false);
answer->setType(zeus::Buffer::typeMessage::data);
int32_t tmpSize = ZEUS_MINIMUM_SIZE_MULTIPLE;
if (m_size < ZEUS_MINIMUM_SIZE_MULTIPLE) {
tmpSize = m_size;

View File

@ -90,10 +90,13 @@ bool zeus::FutureBase::appendData(const ememory::SharedPtr<zeus::Buffer>& _value
if (m_data->m_returnData == nullptr) {
return true;
}
if (m_data->m_callbackFinish != nullptr) {
return m_data->m_callbackFinish(*this);
if (m_data->m_returnData->getPartFinish() == true) {
if (m_data->m_callbackFinish != nullptr) {
return m_data->m_callbackFinish(*this);
}
return true;
}
return m_data->m_returnData->getPartFinish();
return false;
}
void zeus::FutureBase::setSynchronous() {
if (m_data == nullptr) {
@ -148,7 +151,8 @@ bool zeus::FutureBase::isFinished() const {
return true;
}
if (m_data->m_returnData == nullptr) {
return true;
// in this case, we are waiting for an answer that the first packet is not arrived
return false;
}
return m_data->m_returnData->getPartFinish();
}

View File

@ -305,6 +305,7 @@ zeus::FutureBase zeus::WebServer::callBinary(uint64_t _transactionId,
const uint32_t& _serviceId) {
ZEUS_VERBOSE("Send [START] ");
if (isActive() == false) {
ZEUS_ERROR("Send [STOP] ==> not connected (no TCP)");
ememory::SharedPtr<zeus::Buffer> obj = zeus::Buffer::create();
obj->setType(zeus::Buffer::typeMessage::answer);
obj->addError("NOT-CONNECTED", "Client interface not connected (no TCP)");
@ -392,4 +393,5 @@ void zeus::WebServer::answerVoid(uint64_t _clientTransactionId, uint32_t _client
answer->setClientId(_clientId);
answer->addParameter();
writeBinary(answer);
}
}

View File

@ -233,9 +233,9 @@ namespace zeus {
* @return
*/
zeus::FutureBase callBinary(uint64_t _transactionId,
const ememory::SharedPtr<zeus::Buffer>& _obj,
zeus::FutureData::ObserverFinish _callback=nullptr,
const uint32_t& _service=0);
const ememory::SharedPtr<zeus::Buffer>& _obj,
zeus::FutureData::ObserverFinish _callback=nullptr,
const uint32_t& _service=0);
public: // section call direct
/**
* @brief

View File

@ -12,8 +12,8 @@ static std::vector<std::pair<std::string, std::string>> mineList = {
/* Video files */
{ "webm", "video/webm"},
{ "asf", "video/x-ms-asf"},
{ "avc", "video/avi"},
{ "avi", "video/avi"},
{ "avc", "video/avi"},
{ "dv", "video/x-dv"},
{ "divx", "video/avi"},
{ "wmv", "video/x-ms-wmv"},
@ -39,8 +39,6 @@ static std::vector<std::pair<std::string, std::string>> mineList = {
{ "mov", "video/quicktime"},
{ "hdmov", "video/quicktime"},
{ "qt", "video/quicktime"},
{ "bin", "video/mpeg2"},
{ "iso", "video/mpeg2"},
/* Audio files */
{ "weba", "audio/webm"},
@ -122,7 +120,7 @@ std::string zeus::getMineType(const std::string& _extention) {
return it.second;
}
}
ZEUS_ERROR(" try to cenvert mine type: " << _extention);
ZEUS_ERROR(" try to convert extention in mine type: '" << _extention << "'");
return "";
}
@ -132,6 +130,6 @@ std::string zeus::getExtention(const std::string& _mineType) {
return it.first;
}
}
ZEUS_ERROR(" try to cenvert extention: " << _mineType);
ZEUS_ERROR(" try to convert mine-type in extention: '" << _mineType << "'");
return "";
}