75 lines
1.4 KiB
C++
75 lines
1.4 KiB
C++
#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);
|
||
}
|
||
}
|
||
}
|