31 lines
760 B
C++
31 lines
760 B
C++
#include "InfoEvent.hpp"
|
|
|
|
#include <cstring>
|
|
#include <sys/socket.h>
|
|
|
|
|
|
namespace drp::event {
|
|
|
|
|
|
void InfoEvent::handle(
|
|
Context& context,
|
|
const packet::GenericPacketContent& content,
|
|
sockaddr* fromAddress,
|
|
const socklen_t fromAddressLength
|
|
) {
|
|
const auto remotePeer = std::make_shared<RemotePeer>();
|
|
|
|
// TODO(Faraphel): first check if the peer is already in the list
|
|
// do not update the time of the list if yes !
|
|
|
|
// save the remote peer information
|
|
remotePeer->address = *reinterpret_cast<sockaddr*>(&fromAddress);
|
|
remotePeer->addressLength = fromAddressLength;
|
|
std::memcpy(&remotePeer->information, &content, sizeof(Peer));
|
|
|
|
// save it in the peers list
|
|
context.remotePeers.push_back(remotePeer);
|
|
}
|
|
|
|
|
|
}
|