#if !defined(AFX_RJ45THREAD_H__EF54C45E_8872_409A_A888_7104CFF5B26C__INCLUDED_)
#define AFX_RJ45THREAD_H__EF54C45E_8872_409A_A888_7104CFF5B26C__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Rj45Thread.h : header file
//

#include "TcpSocket.h"
#include "UdpSocket.h"

#define WM_RJ45_DISCONNECT		(WM_USER + 0x101)
#define WM_RJ45_DATA			(WM_USER + 0x102)
#define WM_RJ45_ERASE_PAGE		(WM_USER + 0x103)
#define WM_RJ45_BEGIN_READ		(WM_USER + 0x104)


/////////////////////////////////////////////////////////////////////////////
// CRj45Wnd window

class CRj45Wnd : public CWnd
{
// Construction
public:
	CRj45Wnd();

// Attributes
public:
	BOOL Create();
	void BeginSavingFile(char * p);
	void EndSavingFile();

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CRj45Wnd)
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CRj45Wnd();

	// Generated message map functions
protected:
	//{{AFX_MSG(CRj45Wnd)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnDestroy();
	//}}AFX_MSG
#if _MSC_VER >= 1300
	afx_msg LRESULT OnSocketClose(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnSocketConnect(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnSocketData(WPARAM wParam, LPARAM lParam);
#else
	afx_msg void OnSocketClose(WPARAM wParam, LPARAM lParam);
	afx_msg void OnSocketConnect(WPARAM wParam, LPARAM lParam);
	afx_msg void OnSocketData(WPARAM wParam, LPARAM lParam);
#endif
	DECLARE_MESSAGE_MAP()

public:
	CTcpSocket	m_tcp;

protected:
	BOOL m_bSavingFile;
	int  m_iTotalFile;
	char * m_pFileBuf;
};

/////////////////////////////////////////////////////////////////////////////
// CRj45Thread thread

class CRj45Thread : public CWinThread
{
	DECLARE_DYNCREATE(CRj45Thread)
public:
	CRj45Thread();
	void operator delete(void* p);

// Attributes
public:
	static HANDLE m_hEventThreadKilled;
	static HANDLE m_hEventProtocol;

	static void PrepareEvent();
	static void UnprepareEvent();

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CRj45Thread)
	public:
	virtual BOOL InitInstance();
	virtual int ExitInstance();
	//}}AFX_VIRTUAL

// Implementation
protected:
	virtual ~CRj45Thread();

	// Generated message map functions
	//{{AFX_MSG(CRj45Thread)
		// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_MSG
	afx_msg void OnDisconnect(WPARAM wParam = 0, LPARAM lParam = 0);
	afx_msg void OnData(WPARAM wParam, LPARAM lParam);
	afx_msg void OnErasePage(WPARAM wParam, LPARAM lParam = 0);
	afx_msg void OnBeginRead(WPARAM wParam, LPARAM lParam);
	DECLARE_MESSAGE_MAP()

protected:
	CRj45Wnd	m_wndRj45;
};

/////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_RJ45THREAD_H__EF54C45E_8872_409A_A888_7104CFF5B26C__INCLUDED_)
