#ifndef __TYPHOON_SERVER_H__
#define __TYPHOON_SERVER_H__

#include "stdint.h"
#include "TyphoonProduct.h"

#ifdef __cplusplus
extern "C" 
{
#endif

#ifdef _WIN32
#ifdef TYPHOON_SOCKS_DLL_IMPLEMENT
#define TYPHOON_SERVER_EXTERN __declspec(dllexport)
#else 
#define TYPHOON_SERVER_EXTERN __declspec(dllimport) 
#endif
#define TYPHOON_STDCALL __stdcall
#else
#define TYPHOON_SERVER_EXTERN /* nothing */
#define TYPHOON_STDCALL
#endif

typedef void (TYPHOON_STDCALL *TyphoonServerProxy_OnConnected)(void *pHandle, const char *userData, int userDataLen);
typedef void (TYPHOON_STDCALL *TyphoonServerProxy_OnDisConnected)(void *pHandle);

typedef struct TyphoonServerProxyConnectionStatusCb
{
    TyphoonServerProxy_OnConnected     pfnOnConnected;
    TyphoonServerProxy_OnDisConnected  pfnOnDisConnected;
}stTyphoonServerProxyConnectionStatusCb;


struct InitServerPrama{
	char* listenAddr;
	uint32_t listenPort;
	uint32_t minSpeed;
	uint32_t maxSpeed;
	int logId;
	char *logPath;
	char *licensePath;
	char* caPath;
	TyphoonAppId_E licenseType;
	char* license;
	bool bUdpGSO;
	int32_t MaxSegmentSize;
	bool bSdnOn;
	void *rootsData;
	int rootsDataLen;
	int FecPercent;
	bool bCompress;
};


/*
 * 初始化代理服务器
 * 参数：
 * param:输入参数结构体
 * 返回值:
 * 0成功，非0失败
 */
TYPHOON_SERVER_EXTERN int TyphoonProxy_InitServer(struct InitServerPrama *param);

/*
 * 去初始化代理服务器
 * 参数：
 * 无
 * 返回值:
 * 0成功，非0失败
 */
TYPHOON_SERVER_EXTERN int TyphoonProxy_UninitServer();

TYPHOON_SERVER_EXTERN uint64_t TyphoonProxy_GetNodeId();

TYPHOON_SERVER_EXTERN void * TyphoonProxy_GetServerInstance();

TYPHOON_SERVER_EXTERN void TyphoonProxy_writeLog(const char * fileName,       
              const char * funcName, 
              unsigned int line, 
              unsigned int level, 
              const char * format, 
              ...);

TYPHOON_SERVER_EXTERN int TyphoonProxy_RestartSdnRoot(void *rootsData, int rootsDataLen);

TYPHOON_SERVER_EXTERN int TyphoonProxy_CheckSdnIsOnline();

TYPHOON_SERVER_EXTERN void TyphoonServerProxy_SetConnectionStatusCb(stTyphoonServerProxyConnectionStatusCb Cb);

TYPHOON_SERVER_EXTERN stTyphoonServerProxyConnectionStatusCb TyphoonServerProxy_GetConnectionStatusCb();

#ifdef __cplusplus
}
#endif

#endif

