mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-17 07:46:36 +02:00
Splitting line, adding agentId to copy constructor and swap
This commit is contained in:
parent
fc382997bd
commit
54a946ee80
2 changed files with 10 additions and 1 deletions
|
@ -84,8 +84,13 @@ int main(int argc, const char * argv[])
|
|||
agentType = packetData[0];
|
||||
unpackSocket(&packetData[1], (sockaddr *)&agentLocalAddress);
|
||||
|
||||
if (agentList.addOrUpdateAgent((sockaddr *)&agentPublicAddress, (sockaddr *)&agentLocalAddress, agentType, agentList.getLastAgentId())) {
|
||||
if (agentList.addOrUpdateAgent((sockaddr *)&agentPublicAddress,
|
||||
(sockaddr *)&agentLocalAddress,
|
||||
agentType,
|
||||
agentList.getLastAgentId())) {
|
||||
|
||||
agentList.increaseAgentId();
|
||||
|
||||
}
|
||||
|
||||
currentBufferPos = broadcastPacket + 1;
|
||||
|
|
|
@ -43,6 +43,9 @@ Agent::Agent(const Agent &otherAgent) {
|
|||
localSocket = new sockaddr;
|
||||
memcpy(localSocket, otherAgent.localSocket, sizeof(sockaddr));
|
||||
|
||||
agentId = *new uint16_t;
|
||||
memcpy(&agentId, &otherAgent.agentId, sizeof(uint16_t));
|
||||
|
||||
if (otherAgent.activeSocket == otherAgent.publicSocket) {
|
||||
activeSocket = publicSocket;
|
||||
} else if (otherAgent.activeSocket == otherAgent.localSocket) {
|
||||
|
@ -153,6 +156,7 @@ void Agent::swap(Agent &first, Agent &second) {
|
|||
swap(first.activeSocket, second.activeSocket);
|
||||
swap(first.type, second.type);
|
||||
swap(first.linkedData, second.linkedData);
|
||||
swap(first.agentId, second.agentId);
|
||||
}
|
||||
|
||||
bool Agent::matches(sockaddr *otherPublicSocket, sockaddr *otherLocalSocket, char otherAgentType) {
|
||||
|
|
Loading…
Reference in a new issue