【VC开源代码栏目提醒】:网学会员--在 VC开源代码编辑为广大网友搜集整理了:ClientSocket.cpp绩等信息,祝愿广大网友取得需要的信息,参考学习。
// ClientSocket.cpp : 实现文件
//
#include "stdafx.h"
#include "ChatClient.h"
#include "ClientSocket.h"
#include ".\clientsocket.h"
#include "ChatClientDlg.h"
// CClientSocket
CClientSocket::CClientSocket()
{
}
CClientSocket::~CClientSocket()
{
}
// CClientSocket 成员函数
void CClientSocket::OnReceive(int nErrorCode)
{//根据type字段决定是接收信息或者是用户登陆/退出消息
// TODO: 在此添加专用代码和/或调用基类
char buf[sizeof(Header)];//用于接收消息头的缓冲区
memset(buf,0,sizeof(buf));
Receive(buf,sizeof(buf));//接收消息头
Header *header = (Header*)buf;//强制转换成消息头结构
int length = header->len;
char type = header->type;
if(type == SEND_MESSAGE)//发送的是信息
{
chatDlg->GetMessage();//接收信息
}
if(type == LOGIN_IO)//是用户登陆/退出消息
{
chatDlg->UpdateUser();//处理用户登陆或退出消息
}
CSocket::OnReceive(nErrorCode);
}
上一篇:
ClientSock.cpp
下一篇:
科研管理杂志简介