/*
|
|
* Node.cpp
|
|
*
|
|
* Created on: 10.01.2017
|
|
* Author: piotrek
|
|
*/
|
|
|
|
#include "Node.h"
|
|
|
|
Node::Node()
|
|
{
|
|
// TODO Auto-generated constructor stub
|
|
|
|
}
|
|
|
|
Node::~Node()
|
|
{
|
|
// TODO Auto-generated destructor stub
|
|
}
|
|
|
|
/*
|
|
* funkcja symuluje typową sytuację: mamy kartę sieciową, a funkcja connectNode jest podłączeniem wtyczki
|
|
* z jednej strony
|
|
*/
|
|
bool Node::connectNode(Node *node, bool firstConnected)
|
|
{
|
|
if (!firstConnected)
|
|
{
|
|
vector<Node*>::iterator it = this->connectedNodes.begin();
|
|
for (; it != this->connectedNodes.end(); ++it) //sprawdzamy, czy połączenia już przypadkiem nie ma
|
|
{
|
|
if (*it == node)
|
|
return false;
|
|
}
|
|
}
|
|
this->connectedNodes.push_back(node); // podłączamy drugi węzeł
|
|
|
|
if (!firstConnected)
|
|
node->connectNode(this, true); // to samo w drugą stronę
|
|
|
|
return true;
|
|
}
|
|
|
|
void Node::send(Packet packet)
|
|
{
|
|
|
|
}
|
|
|
|
Packet Node::recv()
|
|
{
|
|
}
|
|
|
|
void Node::setHostname(string hostname)
|
|
{
|
|
|
|
}
|
|
|
|
void Node::setIp(string ip)
|
|
{
|
|
|
|
}
|
|
|
|
void Node::setMask(string mask)
|
|
{
|
|
|
|
}
|
|
|
|
string Node::getHostname()
|
|
{
|
|
|
|
}
|
|
|
|
string Node::getIp()
|
|
{
|
|
|
|
}
|
|
|
|
string Node::getMask()
|
|
{
|
|
|
|
}
|
|
|
|
void Node::onRecv()
|
|
{
|
|
|
|
}
|