Objects are sent with correct IDs over network
This commit is contained in:
parent
d9a90dda16
commit
c51b7e7eb1
6 changed files with 51 additions and 31 deletions
|
|
@ -69,7 +69,13 @@ MainServer::MainServer(World& initWorld, const std::string& serverLocalID):
|
|||
if(isDirectConnect)
|
||||
netServer->send_items_to_client(client, RELIABLE_COMMAND_CHANNEL, CLIENT_INITIAL_DATA, isDirectConnect, newClient.serverID, newClient.cursorColor);
|
||||
else {
|
||||
netServer->send_items_to_client(client, RELIABLE_COMMAND_CHANNEL, CLIENT_INITIAL_DATA, isDirectConnect, newClient.serverID, newClient.cursorColor, newClient.displayName, newClient.camCoords, newClient.windowSize, fileDisplayName, clients, data);
|
||||
auto ss(std::make_shared<std::stringstream>());
|
||||
{
|
||||
cereal::PortableBinaryOutputArchive a(*ss);
|
||||
a(CLIENT_INITIAL_DATA, isDirectConnect, newClient.serverID, newClient.cursorColor, newClient.displayName, newClient.camCoords, newClient.windowSize, fileDisplayName, clients, data);
|
||||
world.stringListTest.write_create_message(a);
|
||||
}
|
||||
netServer->send_string_stream_to_client(client, RELIABLE_COMMAND_CHANNEL, ss);
|
||||
for(auto& [id, rData] : data.resources) {
|
||||
netServer->send_items_to_client(client, RESOURCE_COMMAND_CHANNEL, CLIENT_NEW_RESOURCE_ID, id);
|
||||
netServer->send_items_to_client(client, RESOURCE_COMMAND_CHANNEL, CLIENT_NEW_RESOURCE_DATA, rData);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "Helpers/HsvRgb.hpp"
|
||||
#include "Helpers/MathExtras.hpp"
|
||||
#include "Helpers/Networking/ByteStream.hpp"
|
||||
#include "Helpers/NetworkingObjects/NetObjManager.hpp"
|
||||
#include "Helpers/VersionNumber.hpp"
|
||||
#include "Server/CommandList.hpp"
|
||||
#include "MainProgram.hpp"
|
||||
|
|
@ -71,12 +72,14 @@ World::World(MainProgram& initMain, OpenWorldInfo& worldInfo):
|
|||
con.client_send_items_to_server(RELIABLE_COMMAND_CHANNEL, SERVER_INITIAL_DATA, displayName, false);
|
||||
|
||||
using namespace NetworkingObjects;
|
||||
stringListTest = netObjMan.make_obj<NetObjOrderedList<std::string>>();
|
||||
stringListTest->emplace_back_direct(stringListTest, "Hello");
|
||||
stringListTest->emplace_back_direct(stringListTest, "World");
|
||||
stringListTest->emplace_back_direct(stringListTest, "Test");
|
||||
for(const NetObjOrderedListObjectInfoPtr<std::string>& o : stringListTest->get_data())
|
||||
std::cout << "At position: " << o->get_pos() << " we have string: \"" << *o->get_obj() << "\" with object id " << o->get_obj().get_net_id().to_string() << std::endl;
|
||||
if(netObjMan.is_server()) {
|
||||
stringListTest = netObjMan.make_obj<NetObjOrderedList<std::string>>();
|
||||
stringListTest->emplace_back_direct(stringListTest, "Hello");
|
||||
stringListTest->emplace_back_direct(stringListTest, "World");
|
||||
stringListTest->emplace_back_direct(stringListTest, "Test");
|
||||
for(const NetObjOrderedListObjectInfoPtr<std::string>& o : stringListTest->get_data())
|
||||
std::cout << "At position: " << o->get_pos() << " we have string: \"" << *o->get_obj() << "\" with object id " << o->get_obj().get_net_id().to_string() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void World::init_client_callbacks() {
|
||||
|
|
@ -96,6 +99,10 @@ void World::init_client_callbacks() {
|
|||
message(canvasScale);
|
||||
drawProg.initialize_draw_data(message);
|
||||
message(bMan, gridMan);
|
||||
stringListTest = netObjMan.read_create_message<NetworkingObjects::NetObjOrderedList<std::string>>(message, nullptr);
|
||||
std::cout << "Client print: " << std::endl;
|
||||
for(const NetworkingObjects::NetObjOrderedListObjectInfoPtr<std::string>& o : stringListTest->get_data())
|
||||
std::cout << "At position: " << o->get_pos() << " we have string: \"" << *o->get_obj() << "\" with object id " << o->get_obj().get_net_id().to_string() << std::endl;
|
||||
}
|
||||
nextClientID = get_max_id(ownID);
|
||||
clientStillConnecting = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue