2022-05-24 02:01:36 +00:00
|
|
|
|
#include "SockIoServer.h"
|
2022-05-23 02:35:42 +00:00
|
|
|
|
#include "SockIoUser.h"
|
|
|
|
|
#include "base/HGInfo.h"
|
|
|
|
|
|
|
|
|
|
namespace ver_1
|
|
|
|
|
{
|
2022-05-23 10:29:23 +00:00
|
|
|
|
SockIoServer::SockIoServer(HGMsgPump msgPump, ManagerV1* manager)
|
|
|
|
|
: WebServer(msgPump)
|
2022-05-23 02:35:42 +00:00
|
|
|
|
{
|
2022-05-23 10:29:23 +00:00
|
|
|
|
m_manager = manager;
|
2022-05-23 02:35:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SockIoServer::~SockIoServer()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-23 10:29:23 +00:00
|
|
|
|
ManagerV1* SockIoServer::GetManger()
|
|
|
|
|
{
|
|
|
|
|
return m_manager;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-23 02:35:42 +00:00
|
|
|
|
void SockIoServer::Connect(const ConnectParam* param)
|
|
|
|
|
{
|
|
|
|
|
assert(NULL != param && this == param->svr);
|
|
|
|
|
|
|
|
|
|
WebUser* user = new SockIoUser(this, m_currUserId, param->ip, param->port, param->socket);
|
|
|
|
|
user->Open();
|
|
|
|
|
++m_currUserId;
|
|
|
|
|
m_vectorUser.push_back(user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SockIoServer::Command(const SockIoCmdParam* param)
|
|
|
|
|
{
|
|
|
|
|
assert(NULL != param && this == param->svr);
|
|
|
|
|
|
|
|
|
|
int nIndex = GetUserIndex(param->usrId);
|
|
|
|
|
if (-1 != nIndex)
|
|
|
|
|
{
|
|
|
|
|
((SockIoUser*)m_vectorUser[nIndex])->HandleCmd(param);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SockIoServer::Event(const SockIoEvtParam* param)
|
|
|
|
|
{
|
|
|
|
|
assert(NULL != param && this == param->svr);
|
|
|
|
|
|
|
|
|
|
int nIndex = GetUserIndex(param->usrId);
|
|
|
|
|
if (-1 != nIndex)
|
|
|
|
|
{
|
|
|
|
|
((SockIoUser*)m_vectorUser[nIndex])->HandleEvent(param);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|