sendpack qui fonctionne avec le client

This commit is contained in:
MarcEricMartel 2023-10-23 16:20:52 -04:00
parent 590220bc92
commit 49240635b6
3 changed files with 19 additions and 9 deletions

View File

@ -116,5 +116,15 @@ namespace netprot {
bool Deserialize(ErrorLog* errlog, char* buf, const uint32_t buflen); // srv
PacketType getType(char* buf, uint32_t buflen); // srv/cli
}
template <class T> void sendPack(SOCKET sock, T* pack, char** buf, uint32_t* buflen);
template <class T>
void sendPack(SOCKET sock, T* pack, char** buf, uint32_t* buflen) {
netprot::Serialize(pack, buf, buflen);
send(sock, *buf, *buflen, 0);
*buflen = BUFFER_LENGTH;
}
};
#endif

View File

@ -33,7 +33,7 @@ private:
std::map<Timestamp, netprot::Output> m_output_manifest;
std::map<Timestamp, netprot::Chat> m_chatlog;
SOCKET m_sock;
SOCKET m_sock_tcp, m_sock_udp;
sockaddr_in m_addr;
netprot::LoginInfo m_loginfo;
netprot::PlayerInfo m_playinfo;

View File

@ -41,15 +41,15 @@ private:
void buildIdList(size_t size);
uint64_t getUniqueId();
template <class T> void sendPack(SOCKET sock, T* pack, char** buf, uint32_t* buflen);
//template <class T> void sendPack(SOCKET sock, T* pack, char** buf, uint32_t* buflen);
};
template <class T>
void Server::sendPack(SOCKET sock, T* pack, char** buf, uint32_t* buflen) {
netprot::Serialize(pack, buf, buflen);
send(sock, *buf, *buflen, 0);
*buflen = BUFFER_LENGTH;
}
//template <class T>
//void Server::sendPack(SOCKET sock, T* pack, char** buf, uint32_t* buflen) {
// netprot::Serialize(pack, buf, buflen);
// send(sock, *buf, *buflen, 0);
// *buflen = BUFFER_LENGTH;
//}
#endif