69 lines
1.3 KiB
C++
69 lines
1.3 KiB
C++
/*********************************************************************
|
|
*
|
|
* overview:
|
|
* subscribe to FDAA data
|
|
*
|
|
*
|
|
* copyright: Shanghai Baosight Software Co., Ltd.
|
|
*
|
|
* Version history
|
|
* 1.0 2020-05-21 zoufuzhou create
|
|
*
|
|
*********************************************************************/
|
|
#pragma once
|
|
#include <iostream>
|
|
#include <sys/socket.h>
|
|
#include <sys/types.h>
|
|
#include <stdlib.h>
|
|
#include <netinet/in.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include <arpa/inet.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <sstream>
|
|
#include <string>
|
|
#include <IceUtil/Thread.h>
|
|
#include <zlib/MemTable.hpp>
|
|
#include <zlib/MessageDefine.h>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
class SubscribeFDA : public IceUtil::Thread
|
|
{
|
|
private:
|
|
int sHost;
|
|
struct sockaddr_in myaddr;//服务器地址
|
|
int retVal;//调用Socket函数的返回
|
|
char buffer[BUFF_SIZE];
|
|
string conip,m_subaddr;
|
|
int conport;
|
|
int iMode;
|
|
int on;
|
|
int subsize;//订阅点的个数
|
|
|
|
bool m_completed;
|
|
int m_totallength;;
|
|
int m_isrun;
|
|
TCACHE m_tcache;
|
|
private:
|
|
bool Connect();
|
|
bool SubscribeMsg();
|
|
bool Subscribe();
|
|
|
|
void AssembleMsg(const char* buffer,int length);
|
|
public:
|
|
|
|
virtual void run();
|
|
|
|
SubscribeFDA(const string& ip,int port,const string& subaddr);
|
|
|
|
void subscribe(const string& tags);
|
|
virtual ~SubscribeFDA(void);
|
|
|
|
};
|
|
|
|
|