Commit ce30629e by Carwyn

Improved: 1. 增加获取客户端Socket的入口;

parent eee0b887
......@@ -11,7 +11,8 @@ using namespace rapidjson;
FMApiRelay::FMApiRelay() :
_response(0),
_request(0)
_request(0),
_socket(-1)
{
}
......@@ -36,6 +37,16 @@ BOOL FMApiRelay::Transfer( LPSTR data, LPSTR &rsp, UINT &rsp_len )
return TRUE;
}
void FMApiRelay::SetSocketDescriptor(const SOCKET s)
{
_socket = s;
}
SOCKET FMApiRelay::GetSocketDescriptor() const
{
return _socket;
}
INT FMApiRelay::_ParseRequest(LPSTR data)
{
......
......@@ -25,7 +25,8 @@ public:
const char * Request() { return _request; }
const char * Response() { return _response; }
virtual BOOL Transfer(LPSTR data, LPSTR &rsp, UINT &rsp_len);
void SetSocketDescriptor(const SOCKET s);
SOCKET GetSocketDescriptor() const;
protected:
virtual INT _ParseRequest(LPSTR data);
virtual BOOL _GetResponse(LPSTR &rsp, UINT &len);
......@@ -35,6 +36,7 @@ protected:
char *_response;
char *_request;
FMApiCfg _cfg;
SOCKET _socket;
};
#ifdef __cplusplus
......
......@@ -109,6 +109,7 @@ BOOL FMSockServer::_Listen()
//! Receive length first
io_data->buffer.len = sizeof(io_data->header);
io_data->buffer.buf = (char*)&io_data->header;
_relay->SetSocketDescriptor(sclient);
io_data->relay = _relay;
io_data->socket = sclient;
io_data->offset = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment