/*
    Copyright 2004-2005 Electronic Arts Inc.
*/

// --- Include guard

#ifndef EA_GAMETALK_GAMETALKPROTOCOL_H
#define EA_GAMETALK_GAMETALKPROTOCOL_H

// --- Includes
#include "GameTalk/IGameTalkProtocol.h"
#include <GameTalk/Utility.h>
#include "realcomm.h"

namespace EA
{
    namespace GameTalk
    {
		class GameTalkProtocol : public IGameTalkProtocol, public REALCOMM::CONNECTION_CALLBACK
        {
        public:
            GameTalkProtocol(const char* const ipAddress, const int port = EA::GameTalk::IGameTalkProtocol::DEFAULT_GAMETALK_PORT);
            GameTalkProtocol(const int port = EA::GameTalk::IGameTalkProtocol::DEFAULT_GAMETALK_PORT);
            virtual ~GameTalkProtocol();

			virtual bool IsConnected();
            virtual bool Send(void* buffer, size_t msgSize);
            virtual int Poll();
			
			virtual u_int ConnectionCallback(REALCOMM::CONNECTION_CALLBACK::MSG msg, u_int wParam, u_int lParam, REALCOMM::CONNECTION *pConnection);

		private:
            GameTalkProtocol(const GameTalkProtocol& nc);
            GameTalkProtocol & operator=(const GameTalkProtocol& nc);

			void ClientConnected(REALCOMM::CONNECTION* connection);
			void ClientDisconnected(REALCOMM::CONNECTION* connection);

			REALCOMM::CONNECTION_TCP* InitializeRealComm();

			// The connection we send data out on.
			REALCOMM::CONNECTION* mConnection;
		};
    }
}

#endif  //  EA_GAMETALK_GAMETALKPROTOCOL_H

