code_app/sdk/webservice/WSServer.cpp

75 lines
1.4 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "WSServer.h"
#include "WSUser.h"
#include "base/HGInfo.h"
#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);
#if 0
if (!m_vectorUser.empty())
{
#if defined(HG_CMP_MSC)
closesocket(param->socket);
#else
close(param->socket);
#endif
return;
}
#endif
WebUser* user = new WSUser(this, m_currUserId, param->ip, param->port, param->socket);
user->Open();
++m_currUserId;
m_vectorUser.push_back(user);
#if defined(HG_CMP_MSC)
sprintf(nid.szTip, "扫描服务程序(连接数 %u", m_vectorUser.size());
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);
}
}
}