code_app/sdk/webservice/WSServer.cpp

75 lines
1.4 KiB
C++
Raw Permalink Normal View History

#include "WSServer.h"
#include "WSUser.h"
#include "base/HGInfo.h"
2023-03-20 13:03:28 +00:00
#if defined(HG_CMP_MSC)
#include <shellapi.h>
extern ULONG taskbarMsgId;
extern NOTIFYICONDATAA nid;
#endif
namespace ver_2
{
WSServer::WSServer(HGMsgPump msgPump, ManagerV2* manager)
: WebServer(msgPump)
{
m_manager = manager;
}
WSServer::~WSServer()
{
}
ManagerV2* WSServer::GetManger()
{
return m_manager;
}
void WSServer::Connect(const ConnectParam* param)
{
assert(NULL != param && this == param->svr);
2023-08-03 03:14:31 +00:00
#if 0
if (!m_vectorUser.empty())
{
#if defined(HG_CMP_MSC)
closesocket(param->socket);
#else
close(param->socket);
#endif
return;
}
2023-08-03 03:14:31 +00:00
#endif
WebUser* user = new WSUser(this, m_currUserId, param->ip, param->port, param->socket);
user->Open();
++m_currUserId;
m_vectorUser.push_back(user);
2023-03-20 13:03:28 +00:00
#if defined(HG_CMP_MSC)
2023-08-03 03:14:31 +00:00
sprintf(nid.szTip, "扫描服务程序(连接数 %u", m_vectorUser.size());
2023-03-20 13:03:28 +00:00
Shell_NotifyIconA(NIM_MODIFY, &nid);
#endif
}
void WSServer::Command(const WSCmdParam* param)
{
assert(NULL != param && this == param->svr);
int nIndex = GetUserIndex(param->usrId);
if (-1 != nIndex)
{
((WSUser*)m_vectorUser[nIndex])->HandleCmd(param);
}
}
void WSServer::Event(const WSEvtParam* param)
{
assert(NULL != param && this == param->svr);
int nIndex = GetUserIndex(param->usrId);
if (-1 != nIndex)
{
((WSUser*)m_vectorUser[nIndex])->HandleEvent(param);
}
}
}