示例#1
0
void CServerDlg::OnBnClickedStart()
{
	//m_Server.SetWorkerThreadCount(2);
	//m_Server.SetMaxShutdownWaitTime(100000000);
	//m_Server.SetMaxDatagramSize(50);
	//m_Server.SetDetectAttempts(0);

	//m_Server.SetDetectAttempts(0);
	//m_Server.SetDetectInterval(0);

	//m_Server.SetSendPolicy(SP_SAFE);

	m_Address.GetWindowText(m_strAddress);
	m_strAddress.Trim();

	SetAppState(ST_STARTING);

	if(m_Server.Start(ADDRESS, PORT))
	{
		::LogServerStart(ADDRESS, PORT);
		SetAppState(ST_STARTED);
	}
	else
	{
		::LogServerStartFail(m_Server.GetLastError(), m_Server.GetLastErrorDesc());
		SetAppState(ST_STOPPED);
	}
}
示例#2
0
void CClientDlg::OnBnClickedStop()
{
	SetAppState(ST_STOPPING);

	for(size_t i = 0; i < m_vtClients.Size(); i++)
	{
		CUdpClientPtr* pSocket = m_vtClients[i];

		if((*pSocket)->Stop())
			::LogClientStopping((DWORD)i + 1);
		//else
		//	ASSERT(FALSE);
	}

	::WaitWithMessageLoop(100L);

	CString strMsg;
	strMsg.Format(	_T(" *** Summary: expect -  %lld, send - %lld, recv - %lld"),
					m_llExpectReceived, m_llTotalSent, m_llTotalReceived);

	::LogMsg(strMsg);

	if(m_llExpectReceived == m_llTotalSent && m_llTotalSent == m_llTotalReceived)
		strMsg.Format(_T(" *** Success: time consuming -  %u millisecond !"), m_dwTimeconsuming);
	else
		strMsg.Format(_T(" *** Fail: manual terminated ? (or data lost)"));

	::LogMsg(strMsg);

	SetAppState(ST_STOPPED);
}
示例#3
0
void CServerDlg::OnBnClickedStart()
{
	SetAppState(ST_STARTING);

	if(::HP_Server_Start(m_HttpServer, ADDRESS, HTTP_PORT))
	{
		::LogServerStart(ADDRESS, HTTP_PORT, HTTP_NAME);

		if(::HP_Server_Start(m_HttpsServer, ADDRESS, HTTPS_PORT))
		{
			::LogServerStart(ADDRESS, HTTPS_PORT, HTTPS_NAME);
			SetAppState(ST_STARTED);
		}
		else
		{
			::HP_Server_Stop(m_HttpServer);

			::LogServerStartFail(::HP_Server_GetLastError(m_HttpsServer), ::HP_Server_GetLastErrorDesc(m_HttpsServer), HTTPS_NAME);
			SetAppState(ST_STOPPED);
		}
	}
	else
	{
		::LogServerStartFail(::HP_Server_GetLastError(m_HttpServer), ::HP_Server_GetLastErrorDesc(m_HttpServer), HTTP_NAME);
		SetAppState(ST_STOPPED);
	}
}
示例#4
0
void CClientDlg::OnBnClickedStart()
{
	SetAppState(ST_STARTING);

	CString strAddress;
	CString strPort;

	m_Address.GetWindowText(strAddress);
	m_Port.GetWindowText(strPort);

	USHORT usPort	= (USHORT)_ttoi(strPort);
	m_bAsyncConn	= m_Async.GetCheck();

	::LogClientStarting(strAddress, usPort);

	if(m_Client.Start(strAddress, usPort, m_bAsyncConn))
	{

	}
	else
	{
		::LogClientStartFail(m_Client.GetLastError(), m_Client.GetLastErrorDesc());
		SetAppState(ST_STOPED);
	}
}
示例#5
0
void CClientDlg::OnBnClickedStart()
{
    SetAppState(ST_STARTING);

    CString strPort;

    m_Address.GetWindowText(m_strAddress);
    m_Port.GetWindowText(strPort);

    m_usPort	= (USHORT)_ttoi(strPort);
    m_dwConnID	= 0;

    m_pkgInfo.Reset();

    ::LogClientStarting(m_strAddress, m_usPort);

    if(m_Agent->Start(LOCAL_ADDRESS, TRUE))
    {
        SetAppState(ST_STARTED);
    }
    else
    {
        ::LogClientStartFail(m_Agent->GetLastError(), m_Agent->GetLastErrorDesc());
        SetAppState(ST_STOPED);
    }
}
void CVMPIServiceConnMgr::HandlePacket( const char *pData, int len )
{
	switch( pData[0] )
	{
		case VMPI_KILL_PROCESS:
		{
			HandlePacket_KILL_PROCESS( NULL );
		}
		break;
		
		case VMPI_SERVICE_DISABLE:
		{
			KillRunningProcess( "Got a VMPI_SERVICE_DISABLE packet", true );
			SetAppState( VMPI_SERVICE_STATE_DISABLED );
			SaveStateToRegistry();
		}
		break;

		case VMPI_SERVICE_ENABLE:
		{
			if ( g_iCurState == VMPI_SERVICE_STATE_DISABLED )
			{
				SetAppState( VMPI_SERVICE_STATE_IDLE );
			}
			SaveStateToRegistry();
		}
		break;

		case VMPI_SERVICE_UPDATE_PASSWORD:
		{
			const char *pStr = pData + 1;
			SetPassword( pStr );
			
			// Send out the new state.
			SendCurStateTo( -1 );
		}
		break;

		case VMPI_SERVICE_SCREENSAVER_MODE:
		{
			g_bScreensaverMode = (pData[1] != 0);
			SendCurStateTo( -1 );
			SaveStateToRegistry();
		}
		break;

		case VMPI_SERVICE_EXIT:
		{
			Msg( "Got a VMPI_SERVICE_EXIT packet.\n ");
			ServiceHelpers_ExitEarly();
		}
		break;
	}
}
示例#7
0
void CServerDlg::OnBnClickedStart()
{
	CString strPort;
	m_Port.GetWindowText(strPort);
	USHORT usPort = (USHORT)_ttoi(strPort);

	if(usPort == 0)
	{
		MessageBox(_T("Listen Port invalid, pls check!"), _T("Params Error"), MB_OK);
		m_Port.SetFocus();
		return;
	}

	EnSendPolicy enSendPolicy = (EnSendPolicy)m_SendPolicy.GetCurSel();

	CString strThreadCount;
	m_ThreadCount.GetWindowText(strThreadCount);
	int iThreadCount = _ttoi(strThreadCount);

	if(iThreadCount == 0)
		iThreadCount = min((::SysGetNumberOfProcessors() * 2 + 2), 500);
	else if(iThreadCount < 0 || iThreadCount > 500)
	{
		m_ThreadCount.SetFocus();
		return;
	}

	SetAppState(ST_STARTING);

	Reset();

	m_Server->SetSendPolicy(enSendPolicy);
	m_Server->SetWorkerThreadCount(iThreadCount);

	//m_Server->SetFreeSocketObjPool(500);
	//m_Server->SetFreeSocketObjHold(1500);
	//m_Server->SetFreeBufferObjPool(2000);
	//m_Server->SetFreeBufferObjHold(6000);
	//m_Server->SetSocketListenQueue(2000);
	//m_Server->SetAcceptSocketCount(2000);


	if(m_Server->Start(DEFAULT_ADDRESS, usPort))
	{
		::LogServerStart(DEFAULT_ADDRESS, usPort);
		SetAppState(ST_STARTED);
	}
	else
	{
		::LogServerStartFail(m_Server->GetLastError(), m_Server->GetLastErrorDesc());
		SetAppState(ST_STOPPED);
	}
}
示例#8
0
void CServerDlg::OnBnClickedStop()
{
	SetAppState(ST_STOPPING);

	if(::HP_Server_Stop(m_spThis->m_pServer))
	{
		::LogServerStop();
		SetAppState(ST_STOPPED);
	}
	else
	{
		ASSERT(FALSE);
	}
}
示例#9
0
void CClientDlg::OnBnClickedStop()
{
	SetAppState(ST_STOPPING);
	::LogClientStopping(m_pClient->GetConnectionID());

	m_pClient->Stop();

	while(m_pClient->GetState() != SS_STOPPED)
		::Sleep(50);

	if(!m_bListener) ::PostOnClose(m_pClient->GetConnectionID());

	SetAppState(ST_STOPPED);
}
示例#10
0
void CClientDlg::OnBnClickedStop()
{
	SetAppState(ST_STOPING);

	if(m_Client.Stop())
	{
		::LogClientStop(m_Client.GetConnectionID());
		SetAppState(ST_STOPED);
	}
	else
	{
		ASSERT(FALSE);
	}
}
示例#11
0
void CServerDlg::OnBnClickedStop()
{
	SetAppState(ST_STOPPING);

	if(m_Server->Stop())
	{
		::LogServerStop();
		SetAppState(ST_STOPPED);
	}
	else
	{
		ASSERT(FALSE);
	}
}
示例#12
0
//------------------------------------------------------------------------------
static bool ProcessMessages()
{
   static const int MaxEvents = 255;
   static const U32 Mask = 
      SDL_QUITMASK | SDL_VIDEORESIZEMASK | SDL_VIDEOEXPOSEMASK |
      SDL_ACTIVEEVENTMASK | SDL_SYSWMEVENTMASK | 
      SDL_EVENTMASK(SDL_USEREVENT);
   static SDL_Event events[MaxEvents];
 
   SDL_PumpEvents();
   S32 numEvents = SDL_PeepEvents(events, MaxEvents, SDL_GETEVENT, Mask);
   if (numEvents == 0)
      return true;
   for (int i = 0; i < numEvents; ++i)
   {
      SDL_Event& event = events[i];
      switch (event.type)
      {
         case SDL_QUIT:
            return false;
            break;
         case SDL_VIDEORESIZE:
         case SDL_VIDEOEXPOSE:
            Game->refreshWindow();
            break;
         case SDL_USEREVENT:
            if (event.user.code == TORQUE_SETVIDEOMODE)
            {
               SetAppState();
               // SDL will send a motion event to restore the mouse position
               // on the new window.  Ignore that if the window is locked.
               if (x86UNIXState->windowLocked())
               {
                  SDL_Event tempEvent;
                  SDL_PeepEvents(&tempEvent, 1, SDL_GETEVENT, 
                     SDL_MOUSEMOTIONMASK);
               }
            }
            break;
         case SDL_ACTIVEEVENT:
            SetAppState();
            break;          
         case SDL_SYSWMEVENT:
            ProcessSYSWMEvent(event);
            break;
      }
   }
   return true;
}
示例#13
0
EnHandleResult CClientDlg::OnAgentShutdown()
{
    ::PostOnShutdown();
    SetAppState(ST_STOPED);

    return HR_OK;
}
示例#14
0
EnHandleResult CClientDlg::OnError(CONNID dwConnID, EnSocketOperation enOperation, int iErrorCode)
{
    ::PostOnError(dwConnID, enOperation, iErrorCode);
    SetAppState(ST_STARTED);

    return HR_OK;
}
示例#15
0
BOOL CClientDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// TODO: Add extra initialization here

	m_TestTimes.SetCurSel(5);
	m_TestInterv.SetCurSel(1);
	m_ThreadCount.SetCurSel(5);
	m_ThreadInterv.SetCurSel(0);
	m_DataLen.SetCurSel(5);
	m_Address.SetWindowText(DEFAULT_ADDRESS);
	m_Port.SetWindowText(DEFAULT_PORT);

	::SetMainWnd(this);
	::SetInfoList(&m_Info);
	SetAppState(ST_STOPED);

	return TRUE;  // return TRUE  unless you set the focus to a control
}
示例#16
0
BOOL CClientDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// TODO: Add extra initialization here

	m_Method.SetCurSel(3);
	m_Schema.SetCurSel(0);

	m_Path.SetWindowText(DEFAULT_PATH);
	m_Address.SetWindowText(DEFAULT_ADDRESS);
	m_Port.SetWindowText(DEFAULT_PORT);
	m_UseCookie.SetCheck(BST_CHECKED);
	m_Listener.SetCheck(BST_CHECKED);

	::SetMainWnd(this);
	::SetInfoList(&m_Info);
	SetAppState(ST_STOPPED);

	m_bUseCookie = FALSE;
	m_bListener	 = FALSE;
	m_bWebSocket = FALSE;

	return TRUE;  // return TRUE  unless you set the focus to a control
}
示例#17
0
void CClientDlg::OnBnClickedStop()
{
    SetAppState(ST_STOPING);

    if(!m_Agent->Stop())
        ASSERT(FALSE);
}
示例#18
0
EnHandleResult CClientDlg::OnClose(CONNID dwConnID)
{
    ::PostOnClose(dwConnID);
    SetAppState(ST_STARTED);

    return HR_OK;
}
示例#19
0
BOOL CClientDlg::CheckStarted(BOOL bRestart)
{
	if(m_pClient == nullptr)
		return FALSE;

	EnServiceState state = m_pClient->GetState();

	if(state == SS_STARTED)
		return TRUE;
	else if(state == SS_STARTING)
	{
		do 
		{
			::Sleep(50);
			state = m_pClient->GetState();
		} while(state != SS_STARTED && state != SS_STOPPED);
	}
	else
	{
		SetAppState(bRestart ? ST_STARTING : ST_STOPPING);

		while(state != SS_STOPPED)
		{
			::Sleep(50);
			state = m_pClient->GetState();
		}

		if(bRestart)
		{
			if(!m_bListener) ::LogOnClose(m_pClient->GetConnectionID());

			OnBnClickedStart();
		}

		state = m_pClient->GetState();
	}

	if(state == SS_STOPPED)
	{
		if(!m_bListener) ::PostOnClose(m_pClient->GetConnectionID());

		SetAppState(ST_STOPPED);
		return FALSE;
	}

	return TRUE;
}
示例#20
0
void CServerDlg::OnBnClickedStop()
{
	SetAppState(ST_STOPPING);

	if(!::HP_Server_Stop(m_HttpsServer))
		ASSERT(FALSE);

	::LogServerStop(HTTPS_NAME);

	if(!::HP_Server_Stop(m_HttpServer))
		ASSERT(FALSE);

	::LogServerStop(HTTP_NAME);

	SetAppState(ST_STOPPED);

}
示例#21
0
void CServerDlg::OnBnClickedStart()
{
	m_Address.GetWindowText(m_strAddress);
	m_strAddress.Trim();

	SetAppState(ST_STARTING);
	//m_Server->SetSocketBufferSize(64);
	if(::HP_Server_Start(m_spThis->m_pServer, ADDRESS, PORT))
	{
		::LogServerStart(ADDRESS, PORT);
		SetAppState(ST_STARTED);
	}
	else
	{
		::LogServerStartFail(::HP_Server_GetLastError(m_spThis->m_pServer), ::HP_Server_GetLastErrorDesc(m_spThis->m_pServer));
		SetAppState(ST_STOPPED);
	}
}
示例#22
0
EnHandleResult CClientDlg::OnClose(IClient* pClient, EnSocketOperation enOperation, int iErrorCode)
{
	iErrorCode == SE_OK ? ::PostOnClose(pClient->GetConnectionID())		:
	::PostOnError(pClient->GetConnectionID(), enOperation, iErrorCode)	;

	SetAppState(ST_STOPPED);

	return HR_OK;
}
示例#23
0
void CClientDlg::OnBnClickedStop()
{
	SetAppState(ST_STOPPING);

	if(::HP_Client_Stop(m_pClient))
		::LogClientStopping(::HP_Client_GetConnectionID(m_pClient));
	else
		ASSERT(FALSE);
}
示例#24
0
void CServerDlg::OnBnClickedStart()
{
	m_Address.GetWindowText(m_strAddress);
	m_strAddress.Trim();

	SetAppState(ST_STARTING);

	if(m_Server.Start(ADDRESS, PORT))
	{
		::LogServerStart(ADDRESS, PORT);
		SetAppState(ST_STARTED);
	}
	else
	{
		::LogServerStartFail(m_Server.GetLastError(), m_Server.GetLastErrorDesc());
		SetAppState(ST_STOPED);
	}
}
示例#25
0
EnHandleResult CClientDlg::OnClose(ITcpClient* pSender, CONNID dwConnID, EnSocketOperation enOperation, int iErrorCode)
{
	iErrorCode == SE_OK ? ::PostOnClose(dwConnID)		:
	::PostOnError(dwConnID, enOperation, iErrorCode)	;

	SetAppState(ST_STOPPED);

	return HR_OK;
}
示例#26
0
void CClientDlg::OnBnClickedStop()
{
	SetAppState(ST_STOPPING);

	if(m_Client->Stop())
		::LogClientStopping(m_Client->GetConnectionID());
	else
		ASSERT(FALSE);
}
示例#27
0
void CClientDlg::OnBnClickedStart()
{
	SetAppState(ST_STARTING);

	CString strAddress;
	CString strPort;

	m_Address.GetWindowText(strAddress);
	m_Port.GetWindowText(strPort);

	USHORT usPort	= (USHORT)_ttoi(strPort);
	BOOL isHttp		= m_Schema.GetCurSel() == 0;

	m_bUseCookie	= m_UseCookie.GetCheck() == BST_CHECKED;
	m_bListener		= m_Listener.GetCheck() == BST_CHECKED;

	if(isHttp)
		m_pClient.reset((IHttpSyncClient*)(new CHttpSyncClient(m_bListener ? this : nullptr)));
	else
	{
		CHttpsSyncClient* pClient = new CHttpsSyncClient(m_bListener ? this : nullptr);
		VERIFY(pClient->SetupSSLContext(SSL_VM_NONE, g_c_lpszPemCertFile, g_c_lpszPemKeyFile, g_c_lpszKeyPasswod, g_c_lpszCAPemCertFileOrPath));
		m_pClient.reset((IHttpSyncClient*)pClient);
	}

	m_pClient->SetUseCookie(m_bUseCookie);

	::LogClientStarting(strAddress, usPort);

	if(m_pClient->Start(strAddress, usPort))
	{
		if(!m_bListener) ::LogOnConnect3(m_pClient->GetConnectionID(), strAddress, usPort);

		SetAppState(ST_STARTED);
	}
	else
	{
		::LogClientStartFail(m_pClient->GetLastError(), m_pClient->GetLastErrorDesc());
		SetAppState(ST_STOPPED);
	}
}
示例#28
0
void CServerDlg::OnBnClickedStart()
{
	CString strPort;
	m_Port.GetWindowText(strPort);
	USHORT usPort = (USHORT)_ttoi(strPort);

	if(usPort == 0)
	{
		MessageBox(_T("Listen Port invalid, pls check!"), _T("Params Error"), MB_OK);
		m_Port.SetFocus();
		return;
	}

	EnSendPolicy enSendPolicy = (EnSendPolicy)m_SendPolicy.GetCurSel();
	EnRecvPolicy enRecvPolicy = (EnRecvPolicy)m_RecvPolicy.GetCurSel();

	SetAppState(ST_STARTING);

	Reset();

	//m_Server->SetFreeSocketObjPool(500);
	//m_Server->SetFreeSocketObjHold(1500);
	//m_Server->SetFreeBufferObjPool(2000);
	//m_Server->SetFreeBufferObjHold(6000);
	//m_Server->SetSocketListenQueue(2000);
	//m_Server->SetAcceptSocketCount(2000);

	m_Server->SetSendPolicy(enSendPolicy);
	m_Server->SetRecvPolicy(enRecvPolicy);

	if(m_Server->Start(DEFAULT_ADDRESS, usPort))
	{
		::LogServerStart(DEFAULT_ADDRESS, usPort);
		SetAppState(ST_STARTED);
	}
	else
	{
		::LogServerStartFail(m_Server->GetLastError(), m_Server->GetLastErrorDesc());
		SetAppState(ST_STOPED);
	}
}
示例#29
0
ISocketListener::EnHandleResult CClientDlg::OnConnect(DWORD dwConnectionID)
{
	CString strAddress;
	USHORT usPort;

	m_Client.GetLocalAddress(strAddress, usPort);

	::PostOnConnect(dwConnectionID, strAddress, usPort);
	SetAppState(ST_STARTED);

	return ISocketListener::HR_OK;
}
示例#30
0
void CServerDlg::OnBnClickedStart()
{
	m_Address.GetWindowText(m_strAddress);
	m_strAddress.Trim();

	SetAppState(ST_STARTING);
	
	::HP_TcpPackServer_SetMaxPackSize(m_spThis->m_pServer, 0xFFF);
	::HP_TcpPackServer_SetPackHeaderFlag(m_spThis->m_pServer, 0x169);

	if(::HP_Server_Start(m_spThis->m_pServer, ADDRESS, PORT))
	{
		::LogServerStart(ADDRESS, PORT);
		SetAppState(ST_STARTED);
	}
	else
	{
		::LogServerStartFail(::HP_Server_GetLastError(m_spThis->m_pServer), ::HP_Server_GetLastErrorDesc(m_spThis->m_pServer));
		SetAppState(ST_STOPPED);
	}
}