#ifndef __GT_CORE_SENDER_H__
#define __GT_CORE_SENDER_H__
#include "gtmessagequeue.h"

class GtSender
{
    public:
        static int sendMessage(int transCode, unsigned char *inData, int inSize, unsigned char *outData, int *outSize);
        /************************************************************
        *功能：读取最近一张票数据文件
        *输入：无
        *输出：lastTicket=票数据结构
        *返回：!=0错误
        */
        static int readLastTicketFile(stLastTicket *lastTicket);

        /************************************************************
        *功能：最近一张票数据文件是否存在
        *输入：无
        *输出：无
        *返回：true,false
        */
        static bool lastTicketFileExist();

    private:
        static unsigned int _userID;
        static unsigned long _terminalID;
        static int _transTimeout;
        static int getSender();
        static void closeSender(int sender);
        static bool checkReceivedMessage(stMessage *msg);
        static int outPackage(stMessage *msg, unsigned char *outData, int *outSize);
        static void inPackage(int transCode, unsigned char *inData, int inSize, stMessage *msg);
        static int writeAndRead(int socketFd, int transCode, unsigned char *inData, int inSize, unsigned char *outData, int *outSize);
        /************************************************************
        *功能：保存最近一张票数据文件
        *输入：lastTicket=票数据结构
        *输出：无
        *返回：!=0错误
        */
        static int writeLastTicketFile(stLastTicket *lastTicket);

        /************************************************************
        *功能：删除最近一张票数据文件
        *输入：无
        *输出：无
        *返回：!=0错误
        */
        static int clearLastTicketFile();
};

#endif
