#ifndef TCONNECTION_AMCS_H
#define TCONNECTION_AMCS_H
#include "tvsp_amcs.hpp"
#include "tclientamcs.hpp"
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <unistd.h>
#include <netinet/in.h>
#include <string>
#include <tmessages_amcs.hpp>
#include <iostream>
#include <fstream>
#include <errno.h>

class TConnection_AMCS{
public:

	//Attributes

	int sock;
	char* enabledIPs[4];
	int currentIP;
	struct sockaddr_in echoserver;

	//CONSTRUCTOR
    	TConnection_AMCS();

	//DESTRUCTOR
    	~TConnection_AMCS();

	//Try Connect method
	//Is used to launch the series of function to connect to AMCS
	bool setUp(TVSP_AMCS activeVSP, TClientAMCS clientQueue);

	//Ping method
	//This method will output the ping results to a file, then reads it.
	bool ping(char* ipAddress);
	

	//Establish method
	//This method try to establish a TCP connection to the AMCS
	bool establish(char* portNumber, int index);

	//reconnec t Fail method
	//This method will loop until a connection has been established with AMCS
	bool reconnectFail(TVSP_AMCS vsps);
	//SendMessage method
	//This method takes the message and send it to AMCS
	bool sendMessage(string messageToSend);

	//receive message method
	//This method receives a message from the server
	bool receiveMessage();

	//softwareComm method
	//This method start the message sending sequence
	bool softwareComm(TVSP_AMCS vsps);

	//presenceOfAMCS method
	//This method verifies the presence of the server AMCS
	bool presenceOfAMCS(TVSP_AMCS vspSettings,int index);

	//establishSearch method
	//This method is used to search for the word Established in the temp file
	bool establishSearch(const string& textFile)
	{
		string line;
    		bool found = false;
	};

	//closeSocket method
	//This method closes the socket to the AMCS
	void closeSocket();
};

#endif
