refactor: Tidy up SPIT 2
This commit is contained in:
@@ -12,7 +12,7 @@ static const char *TAG = "SPIT";
|
||||
SProcessor::SProcessor(string name, string projName, string hostName, string guid, Callbacks calls, InternalCallbacks intern)
|
||||
: mCallbacks(calls),
|
||||
mInternCallbacks(intern),
|
||||
mName(name),
|
||||
mName(name),
|
||||
mGuid(guid),
|
||||
mProjName(projName),
|
||||
mComputerName(hostName) {
|
||||
@@ -84,29 +84,11 @@ std::vector<char> SProcessor::createMessage(Message::OPPart &opPart) {
|
||||
}
|
||||
return {};
|
||||
}
|
||||
// todo Delete SProcessor::mInternCallbacks.sendMessage(Message::OPPart &opPart
|
||||
|
||||
// // void SProcessor::receiveSPITMessage(SClient &rM) {
|
||||
// // char buffer[MAXSPITMESSAGEBYTECOUNT + 1];
|
||||
// // int rdLen;
|
||||
// // while (rM.mStopReceiveMessages == false) {
|
||||
// // rdLen = rM.mSocket.receiveMessage(buffer, MAXSPITMESSAGEBYTECOUNT, nullptr);
|
||||
// // if (rdLen < 0) {
|
||||
// // if (rM.mStopReceiveMessages) {
|
||||
// // return;
|
||||
// // }
|
||||
// // continue;
|
||||
// // }
|
||||
// // auto vec = vector<char>(buffer, buffer + rdLen);
|
||||
// // rM.checkParseMessageData(move(spitMsg));
|
||||
// // // rM.checkParseMessage(move(spitMsg));
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// void SProcessor::resetMessageNumberReceived() {
|
||||
// mMessageNumberReceived = -1;
|
||||
// mOvertakingMessages.clear();
|
||||
// }
|
||||
void SProcessor::resetMessageNumberReceived() {
|
||||
mMessageNumberReceived = -1;
|
||||
mOvertakingMessages.clear();
|
||||
}
|
||||
|
||||
void SProcessor::checkParseMessageData(vector<char> data) {
|
||||
auto message = make_unique<Message>(data);
|
||||
@@ -136,28 +118,7 @@ void SProcessor::checkParseMessageData(vector<char> data) {
|
||||
mMessageNumberReceived = msgNum;
|
||||
parseMessage(*message);
|
||||
|
||||
// check overtaking messages
|
||||
auto it = mOvertakingMessages.begin();
|
||||
while (mOvertakingMessages.size() > 0) {
|
||||
|
||||
msgNumNext = mMessageNumberReceived + 1;
|
||||
if (msgNumNext > 255 || msgNumNext < 1)
|
||||
msgNumNext = 1;
|
||||
|
||||
auto &overtakingMessage = *it;
|
||||
msgNum = (int)(overtakingMessage->getHeader()->getMessageNumber() & 0xFF);
|
||||
|
||||
if (msgNum == msgNumNext) {
|
||||
mMessageNumberReceived = msgNum;
|
||||
parseMessage(*overtakingMessage);
|
||||
mOvertakingMessages.erase(it);
|
||||
|
||||
it = mOvertakingMessages.begin();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mMessageNumberReceived = sendOvertakingMessage(mMessageNumberReceived);
|
||||
} else {
|
||||
// message has overtaken another message
|
||||
addOvertakingMessage(move(message));
|
||||
@@ -184,6 +145,30 @@ void SProcessor::addOvertakingMessage(unique_ptr<Message> message) {
|
||||
mOvertakingMessages.push_back(move(message));
|
||||
}
|
||||
|
||||
int SProcessor::sendOvertakingMessage(int msgNumRec) {
|
||||
// check overtaking messages
|
||||
auto it = mOvertakingMessages.begin();
|
||||
while (mOvertakingMessages.size() > 0) {
|
||||
|
||||
int msgNumNext = msgNumRec + 1;
|
||||
if (msgNumNext > 255 || msgNumNext < 1)
|
||||
msgNumNext = 1;
|
||||
|
||||
auto &overtakingMessage = *it;
|
||||
int msgNum = (int)(overtakingMessage->getHeader()->getMessageNumber() & 0xFF);
|
||||
|
||||
if (msgNum == msgNumNext) {
|
||||
msgNumRec = msgNum;
|
||||
mInternCallbacks.parseMessage(*overtakingMessage);
|
||||
mOvertakingMessages.erase(it);
|
||||
it = mOvertakingMessages.begin();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msgNumRec;
|
||||
}
|
||||
|
||||
void SProcessor::parseMessage(Message &message) {
|
||||
// answerWatchdog();
|
||||
if (!message.getHeader() || !message.getOPPart()) {
|
||||
@@ -193,21 +178,9 @@ void SProcessor::parseMessage(Message &message) {
|
||||
|
||||
switch (message.getType()) {
|
||||
//----- Connection -----
|
||||
case Message::ConnectAnswer::OPFLAG:
|
||||
// parseConnectAnswer(message.getAs<Message::ConnectAnswer>());
|
||||
break;
|
||||
case Message::Disconnect::OPFLAG:
|
||||
// parseDisconnect(message.getAs<Message::Disconnect>());
|
||||
break;
|
||||
case Message::ReportProject::OPFLAG:
|
||||
parseReportProject(message.getAs<Message::ReportProject>());
|
||||
break;
|
||||
case Message::Watchdog::OPFLAG:
|
||||
// parseWatchdog(message.getAs<Message::Watchdog>());
|
||||
break;
|
||||
case Message::WatchdogAnswer::OPFLAG:
|
||||
// parseWatchdogAnswer(message.getAs<Message::WatchdogAnswer>());
|
||||
break;
|
||||
//----- SPIT Project -----
|
||||
case Message::StartProjectTransfer::OPFLAG:
|
||||
parseStartProjectTransfer(message.getAs<Message::StartProjectTransfer>());
|
||||
@@ -253,83 +226,6 @@ void SProcessor::parseMessage(Message &message) {
|
||||
}
|
||||
}
|
||||
|
||||
// void SProcessor::parseConnectAnswer(Message::ConnectAnswer &message) {
|
||||
// if (message.getClientID() != mGuid)
|
||||
// return;
|
||||
|
||||
// mServerID = message.getServerID();
|
||||
// mServerComputerName = message.getServerComputerName();
|
||||
// mServerName = message.getServerName();
|
||||
// mServerStepTime = message.getStepTime();
|
||||
|
||||
// if (message.getConnected() == false) {
|
||||
// disconnectInternal(Connection::NoneServer);
|
||||
// } else {
|
||||
// message.getStepTime();
|
||||
// mConnectionStatus = Connection::Ok;
|
||||
// mDisconnectedByServer = false;
|
||||
// ESP_LOGD(TAG, "connection established");
|
||||
// stopServerAutoDetect(); // normally you should stop the autodetection before you try a connection
|
||||
// // This is redundand
|
||||
// // mStopReceiveMessages = false;
|
||||
|
||||
// // Maybe you want to reconnect, see eventServerDetected(...)
|
||||
// // Here the connection is established -> don't reconnect at eventServerDetected(...)
|
||||
// // _doReconnect = false;
|
||||
// }
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * The SPIT server was closed
|
||||
// * @param message
|
||||
// */
|
||||
// void SProcessor::parseDisconnect(Message::Disconnect &message) {
|
||||
// Connection intCauseDisconnect = Connection::NoneServer;
|
||||
// /*
|
||||
// function<void()> o_Callable = bind(&SProcessor::disconnectInternal, this, intCauseDisconnect);
|
||||
// SPIT_Handler::addCallable(o_Callable);
|
||||
// */
|
||||
// mDisconnectedByServer = true;
|
||||
// SProcessor::disconnectInternal(intCauseDisconnect);
|
||||
// }
|
||||
|
||||
// //----- Watchdog ------
|
||||
// /**
|
||||
// * The SPIT server sends a watchdog message at regular intervals. The client responds immediately with WatchdogAnswer
|
||||
// * Conversely, the client also sends a watchdog message at regular intervals and waits for a WatchdogAnswer message.
|
||||
// * This is used to check if the other side is still present.
|
||||
// * @param message
|
||||
// */
|
||||
// void SProcessor::parseWatchdog(Message::Watchdog &message) {
|
||||
// // ESP_LOGD(TAG, "parse Watchdog ");
|
||||
// Message::WatchdogAnswer o_WatchdogAnswer;
|
||||
// // mInternCallbacks.sendMessage(o_WatchdogAnswer);
|
||||
// }
|
||||
// /**
|
||||
// * The SPIT server sends a watchdog message at regular intervals. The client responds immediately with WatchdogAnswer
|
||||
// * Conversely, the client also sends a watchdog message at regular intervals and waits for a WatchdogAnswer message.
|
||||
// * This is used to check if the other side is still present.
|
||||
// * @param message
|
||||
// */
|
||||
// void SProcessor::parseWatchdogAnswer(Message::WatchdogAnswer &message) {
|
||||
// answerWatchdog(); // is also done by parseMessage
|
||||
// }
|
||||
// void SProcessor::sendWatchdog() {
|
||||
// int intResult{};
|
||||
// Message::Watchdog message;
|
||||
// // intResult = mInternCallbacks.sendMessage(message);
|
||||
// if (intResult < 0) {
|
||||
// ESP_LOGW("WDT", "Failed to send Watchdog msg");
|
||||
// }
|
||||
// }
|
||||
// void SProcessor::eventWatchdogLost() {
|
||||
// if (mConnectionStatus == Connection::TryConnection) {
|
||||
// disconnectInternal(Connection::NoneServer);
|
||||
// } else {
|
||||
// disconnectInternal(Connection::Lost);
|
||||
// }
|
||||
// }
|
||||
|
||||
//----- SPIT Project ------
|
||||
void SProcessor::parseReportProject(Message::ReportProject &message) {
|
||||
ESP_LOGD(TAG, "parse ReportProject");
|
||||
@@ -387,70 +283,6 @@ void SProcessor::parseRequestProjectTransfer(Message::RequestProjectTransfer &me
|
||||
mInternCallbacks.sendMessage(sMEndProjectTransfer);
|
||||
}
|
||||
|
||||
// /* NEW IMPLEMENTATION
|
||||
|
||||
// void SProcessor::parseRequestProjectTransfer(Message::RequestProjectTransfer* message) {
|
||||
// // ESP_LOGD(TAG, "parse RequestProjectTransfer");
|
||||
// thread* o_ThreadSend;
|
||||
// o_ThreadSend = new thread(&this->sendProject, this);
|
||||
// // int intResult;
|
||||
// // Message::StartProjectTransfer* ptrSMStartProjectTransfer;
|
||||
// // Message::EndProjectTransfer* ptrSMEndProjectTransfer;
|
||||
// // int intCount;
|
||||
// // SPITType* ptrSPITType;
|
||||
// // SObject* ptrSPITObject;
|
||||
|
||||
// // //StartProjectTransfer
|
||||
// // NotifyStartProjectTransfer_Client* o_RunnableStart = new NotifyStartProjectTransfer_Client(mSPITClientInterface);
|
||||
// // SPIT_Handler::addRunnable(o_RunnableStart);
|
||||
|
||||
// // ptrSMStartProjectTransfer = new Message::StartProjectTransfer();
|
||||
// // intResult = mInternCallbacks.sendMessage(ptrSMStartProjectTransfer);
|
||||
// // if (intResult < 0) {
|
||||
// // return;
|
||||
// // }
|
||||
// // mWatchdog->answerWatchdog();
|
||||
// // {
|
||||
// // //send all listes SPITTypes
|
||||
// // unique_lock<recursive_mutex> o_LockType(*SPITType::getMutex());
|
||||
// // intCount = SPITType::getSPITTypeCount();
|
||||
// // for (int i = 0; i < intCount; i++) {
|
||||
// // ptrSPITType = mSpitTypes.getEntry(i);
|
||||
// // if (ptrSPITType == nullptr) continue;
|
||||
// // intResult = sendTypeInternal(ptrSPITType);
|
||||
// // if (intResult < 0) return;
|
||||
// // mWatchdog->answerWatchdog();
|
||||
// // this_thread::sleep_for(chrono::milliseconds(7));
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // {
|
||||
// // unique_lock<recursive_mutex> o_LockObject(*SObject::getMutex());
|
||||
// // intCount = mSpitObjects.getEntryCount();
|
||||
// // for (int i = 0; i < intCount; i++) {
|
||||
// // ptrSPITObject = mSpitObjects.getEntry(i);
|
||||
// // if (ptrSPITObject == nullptr) continue;
|
||||
// // intResult = sendSPITObjectInternal(ptrSPITObject);
|
||||
// // if (intResult < 0) return;
|
||||
// // mWatchdog->answerWatchdog();
|
||||
// // this_thread::sleep_for(chrono::milliseconds(7));
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // //EndProjectTransfer
|
||||
// // ptrSMEndProjectTransfer = new Message::EndProjectTransfer();
|
||||
// // intResult = mInternCallbacks.sendMessage(ptrSMEndProjectTransfer);
|
||||
// // if (intResult < 0) {
|
||||
// // return;
|
||||
// // }
|
||||
// // mWatchdog->answerWatchdog();
|
||||
// // NotifyEndProjectTransfer_Client* o_RunnableEnd = new NotifyEndProjectTransfer_Client(mSPITClientInterface);
|
||||
// // SPIT_Handler::addRunnable(o_RunnableEnd);
|
||||
|
||||
// // //Send act
|
||||
// }
|
||||
// */
|
||||
|
||||
void SProcessor::parseStartProjectTransfer(Message::StartProjectTransfer &message) {
|
||||
mCallbacks.onProjectUpdate(ProjUpdate::StartTransfer, mServerProjectID);
|
||||
}
|
||||
@@ -472,48 +304,46 @@ void SProcessor::parseReportType(Message::ReportType &message) {
|
||||
SType *sType;
|
||||
bool isNew = false;
|
||||
bool isChanged = false;
|
||||
{
|
||||
if (message.getServerRemote() == false) {
|
||||
sType = mSpitTypes.getEntry(message.getID());
|
||||
if (sType == nullptr) {
|
||||
// The user's app may veto the SPITType
|
||||
bool createdByClient = false;
|
||||
if (sType) {
|
||||
createdByClient = sType->getCreatedByClient();
|
||||
}
|
||||
if (message.getServerRemote() == false) {
|
||||
sType = mSpitTypes.getEntry(message.getID());
|
||||
if (sType == nullptr) {
|
||||
// The user's app may veto the SPITType
|
||||
bool createdByClient = false;
|
||||
if (sType) {
|
||||
createdByClient = sType->getCreatedByClient();
|
||||
}
|
||||
|
||||
if (mCallbacks.onCheckSpitTypeVeto(false, createdByClient) == false) {
|
||||
ESP_LOGW(TAG, "TypeVeto %s / %s", message.getID().c_str(), message.getName().c_str());
|
||||
return;
|
||||
}
|
||||
auto spitType = make_unique<SType>(message.getID());
|
||||
sType = spitType.get();
|
||||
mSpitTypes.addEntry(move(spitType));
|
||||
isNew = true;
|
||||
}
|
||||
} else {
|
||||
sType = mRemoteSpitTypes.getEntry(message.getID());
|
||||
if (sType == nullptr) {
|
||||
auto spitType = make_unique<SType>(message.getID());
|
||||
sType = spitType.get();
|
||||
mRemoteSpitTypes.addEntry(move(spitType));
|
||||
isNew = true;
|
||||
if (mCallbacks.onCheckSpitTypeVeto(false, createdByClient) == false) {
|
||||
ESP_LOGW(TAG, "TypeVeto %s / %s", message.getID().c_str(), message.getName().c_str());
|
||||
return;
|
||||
}
|
||||
auto spitType = make_unique<SType>(message.getID());
|
||||
sType = spitType.get();
|
||||
mSpitTypes.addEntry(move(spitType));
|
||||
isNew = true;
|
||||
}
|
||||
if (!sType->setMessageOP(message)) {
|
||||
// SPITType is not changable -> send back to the server
|
||||
} else {
|
||||
sType = mRemoteSpitTypes.getEntry(message.getID());
|
||||
if (sType == nullptr) {
|
||||
auto spitType = make_unique<SType>(message.getID());
|
||||
sType = spitType.get();
|
||||
mRemoteSpitTypes.addEntry(move(spitType));
|
||||
isNew = true;
|
||||
}
|
||||
}
|
||||
if (!sType->setMessageOP(message)) {
|
||||
// SPITType is not changable -> send back to the server
|
||||
sendTypeInternal(*sType);
|
||||
return;
|
||||
}
|
||||
|
||||
auto eventType = isNew ? ObjectEvent::Created : ObjectEvent::Changed;
|
||||
// add or change SPITType
|
||||
mCallbacks.onSpitType(eventType, sType->ServerRemote.get(), *sType);
|
||||
|
||||
if (sType != nullptr) {
|
||||
if (sType->setConfirmed(true) == true || isChanged == true) {
|
||||
sendTypeInternal(*sType);
|
||||
return;
|
||||
}
|
||||
|
||||
auto eventType = isNew ? ObjectEvent::Created : ObjectEvent::Changed;
|
||||
// add or change SPITType
|
||||
mCallbacks.onSpitType(eventType, sType->ServerRemote.get(), *sType);
|
||||
|
||||
if (sType != nullptr) {
|
||||
if (sType->setConfirmed(true) == true || isChanged == true) {
|
||||
sendTypeInternal(*sType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -555,23 +385,22 @@ void SProcessor::parseRemoveType(Message::RemoveType &message) {
|
||||
* @param p_SPITType the SPITType vont
|
||||
* @return true = changed, false = not changed maybe p_SPITType is NULL or the SPITType doesn't exists
|
||||
*/
|
||||
bool SProcessor::changeType(SType *p_SPITType) {
|
||||
if (p_SPITType == nullptr)
|
||||
bool SProcessor::changeType(SType *sType) {
|
||||
if (sType == nullptr)
|
||||
return false;
|
||||
SType *ptrSPITType = mSpitTypes.getEntry(p_SPITType->getID());
|
||||
if (ptrSPITType == nullptr)
|
||||
SType *mod = mSpitTypes.getEntry(sType->getID());
|
||||
if (mod == nullptr)
|
||||
return false;
|
||||
|
||||
ptrSPITType->DefaultDelay.set(p_SPITType->DefaultDelay.get());
|
||||
ptrSPITType->DefaultDuration.set(p_SPITType->DefaultDuration.get());
|
||||
ptrSPITType->Fixed.set(p_SPITType->Fixed.get());
|
||||
ptrSPITType->GroupName.set(p_SPITType->GroupName.get());
|
||||
ptrSPITType->Name.set(p_SPITType->Name.get());
|
||||
ptrSPITType->ProjectIndepended.set(p_SPITType->ProjectIndepended.get());
|
||||
|
||||
mCallbacks.onSpitType(ObjectEvent::Changed, false, *ptrSPITType);
|
||||
sendTypeInternal(*ptrSPITType);
|
||||
mod->DefaultDelay.set(sType->DefaultDelay.get());
|
||||
mod->DefaultDuration.set(sType->DefaultDuration.get());
|
||||
mod->Fixed.set(sType->Fixed.get());
|
||||
mod->GroupName.set(sType->GroupName.get());
|
||||
mod->Name.set(sType->Name.get());
|
||||
mod->ProjectIndepended.set(sType->ProjectIndepended.get());
|
||||
|
||||
mCallbacks.onSpitType(ObjectEvent::Changed, false, *mod);
|
||||
sendTypeInternal(*mod);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -584,21 +413,17 @@ bool SProcessor::changeType(SType *p_SPITType) {
|
||||
* @param p_SPITType the id of the SPITType ro remove
|
||||
* @return 0 = is sended, -1 = is not sended
|
||||
*/
|
||||
int SProcessor::removeType(string p_SPITTypeID) {
|
||||
if (p_SPITTypeID.length() <= 0)
|
||||
int SProcessor::removeType(string sType) {
|
||||
if (sType.length() <= 0)
|
||||
return -1;
|
||||
SType *ptrSPITType;
|
||||
{
|
||||
ptrSPITType = mSpitTypes.getEntry(p_SPITTypeID);
|
||||
if (ptrSPITType == nullptr)
|
||||
return -1;
|
||||
Message::RemoveType sMRemoveSPITType;
|
||||
ptrSPITType->fillMessageOP(sMRemoveSPITType);
|
||||
mCallbacks.onSpitType(ObjectEvent::Deleted, false, *ptrSPITType);
|
||||
mSpitTypes.removeEntry(*ptrSPITType);
|
||||
return mInternCallbacks.sendMessage(sMRemoveSPITType);
|
||||
}
|
||||
return -1;
|
||||
SType *mod = mSpitTypes.getEntry(sType);
|
||||
if (mod == nullptr)
|
||||
return -1;
|
||||
Message::RemoveType sMRemoveSPITType;
|
||||
mod->fillMessageOP(sMRemoveSPITType);
|
||||
mCallbacks.onSpitType(ObjectEvent::Deleted, false, *mod);
|
||||
mSpitTypes.removeEntry(*mod);
|
||||
return mInternCallbacks.sendMessage(sMRemoveSPITType);
|
||||
}
|
||||
|
||||
SType *SProcessor::createType(string id, string groupName, string name, uint64_t delay, uint64_t duration, bool fixed, bool projIndipendent) {
|
||||
@@ -750,38 +575,34 @@ int SProcessor::sendObjectInternal(SObject *sObject) {
|
||||
* @param obj the pointer to the changed SPITObject.
|
||||
* @return 0 = sended, -1 = not sended
|
||||
*/
|
||||
bool SProcessor::changeObject(SObject *obj) {
|
||||
if (obj == nullptr)
|
||||
bool SProcessor::changeObject(SObject *sObject) {
|
||||
if (sObject == nullptr)
|
||||
return false;
|
||||
SObject *mod = mSpitObjects.getEntry(sObject->getID());
|
||||
if (mod == nullptr)
|
||||
return false;
|
||||
SType *sType = mSpitTypes.getEntry(sObject->getID());
|
||||
if (mod == nullptr)
|
||||
return false;
|
||||
SObject *sObject;
|
||||
SType *sType;
|
||||
{
|
||||
sObject = mSpitObjects.getEntry(obj->getID());
|
||||
if (sObject == nullptr)
|
||||
return false;
|
||||
sType = mSpitTypes.getEntry(obj->getID());
|
||||
if (sObject == nullptr)
|
||||
return false;
|
||||
|
||||
sObject->setActionAssigned(obj->getActionAssigned());
|
||||
sObject->Delay.set(obj->Delay.get());
|
||||
sObject->Duration.set(obj->Delay.get());
|
||||
sObject->Fixed.set(obj->Fixed.get());
|
||||
sObject->FrameFadeInLength.set(obj->FrameFadeInLength.get());
|
||||
sObject->FrameFadeOutLength.set(obj->FrameFadeOutLength.get());
|
||||
sObject->FrameLength.set(obj->FrameLength.get());
|
||||
sObject->FrameStart.set(obj->FrameStart.get());
|
||||
sObject->Name.set(obj->Name.get());
|
||||
sObject->Remark.set(obj->Remark.get());
|
||||
sObject->SPITTypeID.set(obj->SPITTypeID.get());
|
||||
sObject->ServerParams.set(obj->ServerParams.get());
|
||||
sObject->Track.set(obj->Track.get());
|
||||
sObject->ValueFactor.set(obj->ValueFactor.get());
|
||||
sObject->ValueUse.set(obj->ValueUse.get());
|
||||
mod->setActionAssigned(sObject->getActionAssigned());
|
||||
mod->Delay.set(sObject->Delay.get());
|
||||
mod->Duration.set(sObject->Delay.get());
|
||||
mod->Fixed.set(sObject->Fixed.get());
|
||||
mod->FrameFadeInLength.set(sObject->FrameFadeInLength.get());
|
||||
mod->FrameFadeOutLength.set(sObject->FrameFadeOutLength.get());
|
||||
mod->FrameLength.set(sObject->FrameLength.get());
|
||||
mod->FrameStart.set(sObject->FrameStart.get());
|
||||
mod->Name.set(sObject->Name.get());
|
||||
mod->Remark.set(sObject->Remark.get());
|
||||
mod->SPITTypeID.set(sObject->SPITTypeID.get());
|
||||
mod->ServerParams.set(sObject->ServerParams.get());
|
||||
mod->Track.set(sObject->Track.get());
|
||||
mod->ValueFactor.set(sObject->ValueFactor.get());
|
||||
mod->ValueUse.set(sObject->ValueUse.get());
|
||||
|
||||
mCallbacks.onSpitObject(ObjectEvent::Changed, false, *sType, *sObject);
|
||||
sendObjectInternal(sObject);
|
||||
}
|
||||
mCallbacks.onSpitObject(ObjectEvent::Changed, false, *sType, *mod);
|
||||
sendObjectInternal(mod);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -797,23 +618,19 @@ bool SProcessor::changeObject(SObject *obj) {
|
||||
int SProcessor::removeObject(string objId) {
|
||||
if (objId.length() <= 0)
|
||||
return -1;
|
||||
SType *sType;
|
||||
SObject *sObject;
|
||||
{
|
||||
Message::RemoveObject remObj;
|
||||
Message::RemoveObject remObj;
|
||||
|
||||
sObject = mSpitObjects.getEntry(objId);
|
||||
if (sObject == nullptr)
|
||||
return -1;
|
||||
sType = mSpitTypes.getEntry(sObject->SPITTypeID.get());
|
||||
if (sType == nullptr)
|
||||
return -1;
|
||||
sObject->fillMessageOP(remObj);
|
||||
mCallbacks.onSpitObject(ObjectEvent::Deleted, false, *sType, *sObject);
|
||||
mSpitObjects.removeEntry(*sObject);
|
||||
mInternCallbacks.sendMessage(remObj);
|
||||
}
|
||||
return -1;
|
||||
SObject *sObject = mSpitObjects.getEntry(objId);
|
||||
if (sObject == nullptr)
|
||||
return -1;
|
||||
SType *sType = mSpitTypes.getEntry(sObject->SPITTypeID.get());
|
||||
if (sType == nullptr)
|
||||
return -1;
|
||||
|
||||
sObject->fillMessageOP(remObj);
|
||||
mCallbacks.onSpitObject(ObjectEvent::Deleted, false, *sType, *sObject);
|
||||
mSpitObjects.removeEntry(*sObject);
|
||||
return mInternCallbacks.sendMessage(remObj);
|
||||
}
|
||||
|
||||
// //----- Play SPIT Objects ------
|
||||
|
||||
Reference in New Issue
Block a user