📄 slot.cpp
字号:
#include "stdhdr.h"
#include "main.h"
#include "svc.h"
#include "slot.h"
CSlot::CSlot(CSvc *pSvc, SOCKET sockfd, int id)
{
char buf[80], num[17];
m_id = id;
m_sockfd = sockfd;
pSvc->AddSlot(this);
CSlot *pSlot = pSvc->m_pHead;
strcpy(buf, "User #");
strcat(buf, itoa(m_id, num, 10));
strcat(buf, " has arrived.");
pSvc->SendAll(buf, this);
}
CSlot::~CSlot()
{
char buf[80], num[17];
CSlot *pSlot = m_pSvc->m_pHead;
strcpy(buf, "User #");
strcat(buf, itoa(m_id, num, 10));
strcat(buf, " has just left.");
m_pSvc->SendAll(buf, this);
m_pSvc->RemoveSlot(this);
closesocket(m_sockfd);
}
void CSlot::Send(char *pszSend)
{
send(m_sockfd, pszSend, strlen(pszSend), 0);
}
int CSlot::Recv(char *pszRecv, int n)
{
return recv(m_sockfd, pszRecv, n, 0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -