⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gatewayproxyweb.h

📁 C++实现的brew程序管理器例子
💻 H
字号:
/////////////////////////////////////////////////////////////////////
// Project : GatewayProxy
// File: GatewayProxyWeb.h
// web module of this project
// 2005/03/27
/////////////////////////////////////////////////////////////////////

#ifndef _GATEWAYPROXY_WEB_H_
#define _GATEWAYPROXY_WEB_H_

//---------------- Inculde ------------------
#include "Shell.h"
#include "Web.h"
#include "Source.h"

//#include "GatewayProxyApp.h"
//-------------------------------------------
class CAppsViewer;

class CGatewayProxyWeb
{
public:
	CGatewayProxyWeb(void);
	CGatewayProxyWeb(CAppsViewer *pApp);
	~CGatewayProxyWeb(void);
	//重载new操作符
    void * operator new(unsigned int size);// new operator
	//重载delete操作符
    void operator delete(void * ptr);    // delete operator
//
public:
	// 创建WebAction对象
	boolean Create(CShell *pShell, CWebUtil *pWebUtil);
	// 创建WebAction中的CWeb对象
	boolean CreateWeb();
	// 释放网络连接
	void ReleaseWeb();
	// 设置Web连接的Url
	boolean SetUrl(const char * pszUrl);
	// 进行Web连接,发送缓冲区数据由WebAction类管理、释放
	boolean WebConnect(const char * pszUrl, char *pszSendBuff);
   // 进行安全Web连接
	boolean SSLWebConnect(const char *pszUrl, char *pszSendBuff);
	// 复制接收到的数据到指定缓冲区,如果缓冲区太小,则扩大缓冲区
	boolean CopyRecv(char *&pszRecvBuff, int &nOrigDataSize, int &nBuffSize);
	// 返回当前Web连接是否忙碌(等待接收)
	boolean IsBusy(void)
	{
		return m_bBusy;
	}
	// 获取当前的接收数据
	char *GetRecvBuff()
	{
		return (char *)m_pbRecvBuff;
	}
//
protected:
	// 内部的普通HttpWeb连接
	boolean HttpWebConnect();
	// 内部的安全HttpWeb连接
	boolean SSLHttpWebConnect();
	// 获取Web回应
	void GetResponse(WebOpt *pWebOpt);
	// Web接收回调函数
	static void GotWebResp(CGatewayProxyWeb *pThis)
	{
		if(pThis)
			pThis->OnWebResp();
	}
	// Web读取数据函数
	static void ReadSource(CGatewayProxyWeb *pThis)
	{
		if(pThis)
			pThis->OnReadSource();
	}
	// 重发回调函数
	static void ReSend(CGatewayProxyWeb *pThis)
	{
		if(pThis)
			pThis->OnReSend();
	}
	// 处理Web接收
	void OnWebResp();
	// 读取Web返回的数据
	void OnReadSource();
	// 处理接收到的数据
	void HandleRecv();
	// 重发数据
	void OnReSend();
	// 结束Web调用,返回结果
	void EndWeb(AEEEvent evt, uint32 dwParam1 = 0, uint32 dwParam2 = 0);
protected:
	CShell			*m_pShell;
	CWeb			*m_pWeb;					//Web指针
	CWebResp		*m_pWebResp;				//WebResp指针
	CWebUtil		*m_pWebUtil;				//WebUtil指针,用来URL Encode
	CSourceUtil		*m_pSourceUtil;				//SourceUtil指针
	CSource			*m_pSource;					//Source指针

	AEECallback		m_cbWebResp;				//Web返回回调函数
	AEECallback		m_cbRead;					//读取数据回调函数

	char			*m_pszHeaderBuff;			//Web Head缓冲区
	uint16			m_nHeaderSize;				//Web Head已有数据大小
	uint16			m_nHeaderMaxSize;			//Web Head缓冲区大小

	uint16			m_nSendCount;					//发送计数

	char			*m_pszUrl;						//Web连接的Url

	uint16			m_nError;						//错误
	CAppsViewer		*m_pApp;					//接收消息的类

	boolean			m_bBusy;						//当前是否处于繁忙状态

	char			*m_pszSendBuff;					//发送缓冲区

	byte			*m_pbRecvBuff;					//Web 接收到的数据缓冲区
	uint16			m_nRecvSize;					//接收到的内容长度
	uint16			m_nRecvMaxSize;					//接收缓冲区最大长度
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -