Showing the changes to libraries/networking/src/EntityScriptClient.cpp (1 of 7 files). Show all
Unified · Split
| @@ -69,6 +69,36 @@ bool EntityScriptClient::reloadServerScript(QUuid entityID) { · 68 unmodified lines | ||
| 69 | 69 | return false; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | +void EntityScriptClient::callEntityServerMethod(QUuid entityID, const QString& method, const QStringList& params) { | |
| 73 | + // Send packet to entity script server | |
| 74 | + auto nodeList = DependencyManager::get<NodeList>(); | |
| 75 | + SharedNodePointer entityScriptServer = nodeList->soloNodeOfType(NodeType::EntityScriptServer); | |
| 76 | + | |
| 77 | + if (entityScriptServer) { | |
| 78 | + auto packetList = NLPacketList::create(PacketType::EntityScriptCallMethod, QByteArray(), true, true); | |
| 79 | + | |
| 80 | + packetList->write(entityID.toRfc4122()); | |
| 81 | + | |
| 82 | + auto methodUtf8 = method.toUtf8(); | |
| 83 | + quint16 methodLength = methodUtf8.length(); | |
| 84 | + packetList->writePrimitive(methodLength); | |
| 85 | + packetList->write(methodUtf8); | |
| 86 | + | |
| 87 | + quint16 paramCount = params.length(); | |
| 88 | + packetList->writePrimitive(paramCount); | |
| 89 | + | |
| 90 | + foreach(const QString& param, params) { | |
| 91 | + auto paramUtf8 = param.toUtf8(); | |
| 92 | + quint16 paramLength = paramUtf8.length(); | |
| 93 | + packetList->writePrimitive(paramLength); | |
| 94 | + packetList->write(paramUtf8); | |
| 95 | + } | |
| 96 | + | |
| 97 | + nodeList->sendPacketList(std::move(packetList), *entityScriptServer); | |
| 98 | + } | |
| 99 | +} | |
| 100 | + | |
| 101 | + | |
| 72 | 102 | MessageID EntityScriptClient::getEntityServerScriptStatus(QUuid entityID, GetScriptStatusCallback callback) { |
| 73 | 103 | auto nodeList = DependencyManager::get<NodeList>(); |
| 74 | 104 | SharedNodePointer entityScriptServer = nodeList->soloNodeOfType(NodeType::EntityScriptServer); |