-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMySocket.cpp
More file actions
101 lines (88 loc) · 2.23 KB
/
MySocket.cpp
File metadata and controls
101 lines (88 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// MySocket.cpp : implementation file
//
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "stdafx.h"
#include "MySocket.h"
#include "OpenGLDoc.h"
#include "MyOpenGLView.h"
/////////////////////////////////////////////////////////////////////////////
// MySocket
CMySocket::CMySocket()
{
}
CMySocket::~CMySocket()
{
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CMySocket, CSocket)
//{{AFX_MSG_MAP(CMySocket)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
/////////////////////////////////////////////////////////////////////////////
// MySocket member functions
void CMySocket::SetParent(CView *pWnd)
{
m_pWnd = pWnd;
}
// because CMySocket is derived from CAsyncSocket, these functions are called
// automatically when these events happen. They simply call the related function
// located in the parent class.
// Once an accept happens, call the OnAccept() function of the dlg class
void CMySocket::OnAccept(int iErrorCode)
{
if (iErrorCode == 0)
{
((CMyOpenGLView*)m_pWnd)->OnAccept();
}
else
{
// AfxMessageBox("Error Code: " + (CString)iErrorCode);
}
CSocket::OnAccept(iErrorCode);
}
// none of these functions should execute, but they are here because they help
// with debugging and they are required to be overridden due to the fact
// that they are pure virtual functions in CAsyncSocket
void CMySocket::OnConnect(int iErrorCode)
{
// AfxMessageBox("void CMySocket::OnConnect(int iErrorCode)");
if (iErrorCode == 0)
{
((CMyOpenGLView*)m_pWnd)->OnConnect();
}
CSocket::OnConnect(iErrorCode);
}
void CMySocket::OnClose(int iErrorCode)
{
// AfxMessageBox("void CMySocket::OnClose(int iErrorCode)");
if (iErrorCode == 0)
{
((CMyOpenGLView*)m_pWnd)->OnClose();
}
CSocket::OnClose(iErrorCode);
}
void CMySocket::OnReceive(int iErrorCode)
{
// AfxMessageBox("void CMySocket::OnReceive(int iErrorCode)");
if (iErrorCode == 0)
{
((CMyOpenGLView*)m_pWnd)->OnReceive();
}
CSocket::OnReceive(iErrorCode);
}
void CMySocket::OnSend(int iErrorCode)
{
// AfxMessageBox("void CMySocket::OnSend(int iErrorCode)");
if (iErrorCode == 0)
{
((CMyOpenGLView*)m_pWnd)->OnSend();
}
CSocket::OnSend(iErrorCode);
}
// eof MySocket.cpp