FileSenderThread.h
上传用户:maryhy001
上传日期:2007-05-02
资源大小:2317k
文件大小:2k
- #ifndef _FILESENDER_THREAD_H
- #define _FILESENDER_THREAD_H
- #include "package.h"
- #include "mutex.h"
- #include "thread.h"
- #include "xfile.h"
- #include "socket.h"
- #include "safeVector.h"
- class CFileSenderSocket;
- //class CFileSenderThread :: client socket sending file thread.
- // it inherited from CThread class.
- class NETLIBDLLEXPORT CFileSenderThread : public CThread
- {
- public:
- CFileSenderThread();
- virtual ~CFileSenderThread();
- //create the thread
- bool Create(bool bCreateAndSuspended = false,
- const char* lpszSvrIpAddr = "127.0.0.1",
- uint unPort = 8989);
- //
- bool Create(bool bCreateAndSuspended = false,
- CXClientSocket *pSndSocket = NULL);
- //destroy the thread
- virtual void Destroy();
-
- //set the sending notify event receiver window..
- void Subscribe( HWND hNotifyWnd = NULL );
- //push the file item.
- void pushFile(const char *szFileName);
- protected:
- //send someone file contents.
- int SendFile(string &strfilename);
- int SendFileHeader(string &strfilename);
- int SendFileBody();
- int SendContSignal( bool bIsContinue = true );
- //overrides execute function.
- virtual void Execute();
- //start, stop event process functions.
- virtual void OnStart();
- virtual void OnStop();
-
- private:
- //file sending socket object.
- CXClientSocket *m_pSndSocket;
- //sending file name list.
- CSafeStringList m_lstFileNames;
- //current file object...
- CXFile m_xfile;
- //event receiver ...
- HWND m_hNotifyWnd;
- //mutex object.
- CMutex m_hMutex;
- };
- #endif //_FILESENDER_THREAD_H