Initial
This commit is contained in:
87
remotepsapp/ConnectionThread.cpp
Normal file
87
remotepsapp/ConnectionThread.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
#include <remotepsapp/ConnectionThread.hpp>
|
||||
|
||||
ConnectionThread::ConnectionThread(void)
|
||||
: mIsInConnect(false)
|
||||
{
|
||||
mThreadHandler.setCallback(this,&ConnectionThread::threadHandler);
|
||||
insertHandler(&mThreadHandler);
|
||||
}
|
||||
|
||||
ConnectionThread::ConnectionThread(const ConnectionThread &/*someConnectionThread*/)
|
||||
{ // private implementation
|
||||
}
|
||||
|
||||
ConnectionThread::~ConnectionThread()
|
||||
{
|
||||
removeHandler(&mThreadHandler);
|
||||
if(mIsInConnect){mIsInConnect=false;fatalThreadExit();}
|
||||
}
|
||||
|
||||
ConnectionThread &ConnectionThread::operator=(const ConnectionThread &someConnectionThread)
|
||||
{ // private implementation
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ConnectionThread::handleConnect(const String &serverName)
|
||||
{
|
||||
String *pComputerName=::new String(serverName);
|
||||
ThreadMessage connectMessage(ThreadMessage::TM_USER,MsgConnect,(LONG)pComputerName);
|
||||
mIsInConnect=true;
|
||||
MessageThread::postMessage(connectMessage);
|
||||
}
|
||||
|
||||
DWORD ConnectionThread::threadHandler(ThreadMessage &threadMessage)
|
||||
{
|
||||
switch(threadMessage.message())
|
||||
{
|
||||
case ThreadMessage::TM_CREATE :
|
||||
break;
|
||||
case ThreadMessage::TM_DESTROY :
|
||||
break;
|
||||
case ThreadMessage::TM_USER :
|
||||
if(MsgConnect==threadMessage.userDataOne())
|
||||
{
|
||||
thConnect(*((String*)threadMessage.userDataTwo()));
|
||||
mIsInConnect=false;
|
||||
::delete (String*)threadMessage.userDataTwo();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void ConnectionThread::thConnect(const String &strServerName)
|
||||
{
|
||||
ComInitializer comInitializer;
|
||||
mStrServerName=strServerName;
|
||||
preConnect(strServerName);
|
||||
if(!mRemoteProcessInfo.connect(strServerName))
|
||||
{
|
||||
mConnectionMutex.releaseMutex();
|
||||
errorHandler();
|
||||
return;
|
||||
}
|
||||
connectionHandler(mRemoteProcessInfo);
|
||||
preDisconnect(strServerName);
|
||||
mRemoteProcessInfo.disconnect();
|
||||
mConnectionMutex.releaseMutex();
|
||||
}
|
||||
|
||||
// ******* virtuals
|
||||
|
||||
void ConnectionThread::connectionHandler(RemoteProcessInfo &/*remoteProcessInfo*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ConnectionThread::errorHandler(void)
|
||||
{
|
||||
}
|
||||
|
||||
void ConnectionThread::preConnect(const String &strServerName)
|
||||
{
|
||||
}
|
||||
|
||||
void ConnectionThread::preDisconnect(const String &strServerName)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user