You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.5 KiB
C

3 years ago
// VisionNW.h: interface for the CVisionNW class.
//
//////////////////////////////////////////////////////////////////////
#pragma once
3 months ago
#include <array>
3 years ago
#include <string>
#include "MySocket.h"
#ifdef _DLLCLASS
#undef _DLLCLASS
#endif
#define _DLLCLASS __declspec(dllexport)
3 months ago
constexpr auto MAXSOCKBUF = 4096;
constexpr bool SERVER = true;
constexpr bool CLIENT = false;
3 years ago
class _DLLCLASS CVisionNW
{
public:
3 months ago
// ctor
3 years ago
CVisionNW();
virtual ~CVisionNW();
3 months ago
// methods
void ResetReceiveBuffer();
3 years ago
void OnClose(int nErrorCode);
void OnReceive(int nErrorCode);
void OnSend(int nErrorCode);
void OnConnect(int nErrorCode);
void OnAccept(int nErrorCode);
3 months ago
// attributes
bool m_bTraceData{};
3 years ago
protected:
3 months ago
bool Send(const std::string& strMsg);
bool IsConnectedToServer(void);
bool IsServerActive(void);
bool IsClientConnected(void);
void Disconnect(void);
bool Connect(int nPort, const std::string& strServerName, bool bServer = true);
3 years ago
virtual void ReceiveComm(const char* cpcBuffer, int nSize);
3 months ago
void ProcessMessage(void);
3 years ago
char m_RcvBuff[MAXSOCKBUF];
3 months ago
bool m_bDataComplete{};
int m_nBufferPtr{};
3 years ago
private:
std::string m_strServerName;
3 months ago
bool m_bServerActive{};
bool m_bConnectedToServer{};
bool m_bClientConnected{};
3 years ago
CMySocket m_sListenSocket;
CMySocket m_sConnectSocket;
3 months ago
bool m_bConnectionType{SERVER};
int m_nPort{};
3 years ago
};