/***************************************************************************
                   rc_mngd Control Class Header ( RcMngdControl.h )
                -----------------------------------------

	begin      : 2015/02/04
	copyright  : (C) 2013 Solbox Inc.
	author     : Development 1 Team
					- 2015/02/04 - 1st dadamin
	email      : dev1@solbox.com
	version    : 3.4.0

	CopyRight(C) 2005 Solbox Inc. All Rights reserved.
	Redistribution and use in source and binary forms, with or with out
	modification, are not permitted in outside of Solbox Inc.
***************************************************************************/
#ifndef __RC_MNGD_CONTROL_H__
#define __RC_MNGD_CONTROL_H__

struct LinkInfo
{
	bool master;
	string linkuserseq;
	string linksvcseq;
	string linkrcts;
};

class CRcMngdControl
{
public:
	CRcMngdControl();
	~CRcMngdControl();

	bool Connect(const char* ip, int port, bool usessl = true);

	bool MoveRequest(const char* userseq, const char* svcseq, const char* rcts);
	bool MoveCompleted(const char* userseq, const char* svcseq, const char* rcts);
	bool LinkRequest(struct LinkInfo& selfself, struct LinkInfo& target, const char* linkcode);
	bool ChkSync(const char* userseq, const char* svcseq);
	bool SetSync(const char* userseq, const char* svcseq, bool mstaer, const char* linksvcseq, const char* linkcode);
	bool ChangeRcts(const char* svcseq, const char * syncsvcseq, bool masteryn);

protected:
	bool SendHeader(int bodylen);
	bool SendBody(const char * buf, int snedlen);

	bool ReadHeader(int & outlen);
	bool ReadBody(char * out, int & outlen);

	
private:
	string		m_targetrcts;
	SSL_CTX *	m_ctx;
	BIO *		m_bio;
		
};

#endif // __FHS_CONTROL_H__
