#include "Node.h"
#include "Packet.h"
#include "PacketFactory.h"
#include "Address.h"
#include "Info.h"

int main()
{

   PacketFactory* pf = PacketFactory:: instance();

   Address addr = "ws2";
   Node *n1 = new Node( addr, pf );
   cout << "Address: " << n1->getAddress() << endl;

   Packet *p1 = new Packet( "ws1", "ws2", 12321 );
   Address a1 = p1->getOriginator();
   Address a2 = p1->getDestination(); 
   Info i1 = p1->getInfo();
   if( p1->isDestinated("ws2") )
   	cout << "o: " << a1 << '\t' << "d: " <<  a2 << '\t' << i1 << endl;
   else
	cout << "Unknown destination" << endl;

   if( (n1->accept( *p1 )) )
      cout << "Pacchetto ricevuto" << endl;
   else
      cout << "Pacchetto scartato" << endl;
   
   Packet *sended = n1->send();
   cout << "contents:" << sended->getInfo() << " o: " << sended->getDestination() << endl;
   n1->suspend(34);

  
   
   delete p1;
   delete n1;
   delete sended;

   return 0;
}