Started work on network object system
This commit is contained in:
parent
a2ce579b8b
commit
ed4810e6ee
12 changed files with 394 additions and 74 deletions
|
|
@ -93,6 +93,27 @@ void NetClient::parse_received_messages() {
|
|||
}
|
||||
}
|
||||
|
||||
void NetClient::send_string_stream_to_server(const std::string& channel, const std::shared_ptr<std::stringstream>& ss) {
|
||||
if(isDisconnected)
|
||||
return;
|
||||
|
||||
auto& messageQueue = messageQueues[channel];
|
||||
|
||||
if(channel == UNRELIABLE_COMMAND_CHANNEL) {
|
||||
if(ss->view().length() <= NetLibrary::MAX_UNRELIABLE_MESSAGE_SIZE) // Drop unreliable messages that are too big
|
||||
messageQueue.emplace(NetLibrary::calc_order_for_queued_message(channel, nextMessageOrderToSend), ss);
|
||||
}
|
||||
else {
|
||||
std::vector<std::shared_ptr<std::stringstream>> fragmentedMessage = fragment_message(ss->view(), NetLibrary::FRAGMENT_MESSAGE_STRIDE);
|
||||
if(fragmentedMessage.empty())
|
||||
messageQueue.emplace(NetLibrary::calc_order_for_queued_message(channel, nextMessageOrderToSend), ss);
|
||||
else {
|
||||
for(auto& ss2 : fragmentedMessage)
|
||||
messageQueue.emplace(NetLibrary::calc_order_for_queued_message(channel, nextMessageOrderToSend), ss2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NetLibrary::DownloadProgress NetClient::get_progress_into_fragmented_message(const std::string& channel) const {
|
||||
auto it = pfm.find(channel);
|
||||
if(it == pfm.end())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue