void RemoteDesktop::Network_Client::_Run_Gateway(std::wstring gatewayurl){
	int counter = 0;

	while (_Running && ++counter < MaxConnectAttempts){
		int src_id = -1;
		std::wstring aeskey;
		DEBUG_MSG("Connecting to gateway to get id .. .");
		if (!GetGatewayID_and_Key(src_id, aeskey, gatewayurl)){
			DEBUG_MSG("Failed to connect to gateway . . ");
			continue;
		}
		DEBUG_MSG("Connected to gateway id server . . . %", src_id);


		if (OnConnectingAttempt) OnConnectingAttempt(counter, MaxConnectAttempts);

		auto sock = RemoteDesktop::Connect(_Dst_Port, _Dst_Host);
		if (sock == INVALID_SOCKET) continue;
		if (OnGatewayConnected) OnGatewayConnected(src_id);
		counter = 0;//reset timer
		MaxConnectAttempts = DEFAULTMAXCONNECTATTEMPTS;//set this to a specific value

		std::shared_ptr<SocketHandler> socket(std::make_shared<SocketHandler>(sock, true));
		socket->Exchange_Keys(-1, src_id, aeskey);
		_Run(socket);
		_HandleDisconnect(socket);
		_ShouldDisconnect = false;
	}
	if (MaxConnectAttempts >= DEFAULTMAXCONNECTATTEMPTS){
		//MessageBoxA(NULL, "Could not contact to gateway server. This could be due to your firewall blocking, or the server could be down.\n\nThe Program will exit now.", "Remote Access Tool Gateway Server Down", MB_OK);
	}
	_Running = false;
	_ShouldDisconnect = true;
}
SetPartition CCPivot::Run(const SetPartitionVector& SPV)
{
  srand((unsigned)time(NULL));
  SetPartition sp(_Run(SPV));
  int mindist = SPV.SumOfRandDistance(sp);

  for (int i = 0; i < 49; ++i)
  {
    SetPartition sp2(_Run(SPV));
    int d = SPV.SumOfRandDistance(sp2);
    if (d < mindist)
    {
      mindist = d;
      sp = sp2;
    }
  }
  return sp;
}
status_t
EventDispatcher::SetTo(EventStream* stream)
{
	ETRACE(("event dispatcher: stream = %p\n", stream));

	_Unset();

	if (stream == NULL)
		return B_OK;

	fStream = stream;
	return _Run();
}
void RemoteDesktop::Network_Client::_Run_Standard(int dst_id, std::wstring aeskey){
	int counter = 0;

	while (_Running && ++counter < MaxConnectAttempts){
		if (OnConnectingAttempt) OnConnectingAttempt(counter, MaxConnectAttempts);
		DEBUG_MSG("Connecting to server . . . %", dst_id);
		auto sock = RemoteDesktop::Connect(_Dst_Port, _Dst_Host);
		if (sock == INVALID_SOCKET) continue;
		counter = 0;//reset timer

		MaxConnectAttempts = DEFAULTMAXCONNECTATTEMPTS;//set this to a specific value
		std::shared_ptr<SocketHandler> socket(std::make_shared<SocketHandler>(sock, true));
		socket->Exchange_Keys(dst_id, -1, aeskey);
		_Run(socket);
		_ShouldDisconnect = false;
	}
	std::shared_ptr<SocketHandler> emptysocket;
	if (counter >= MaxConnectAttempts && OnDisconnect)	OnDisconnect(emptysocket);//real disconnect here
	_Running = false;
	_ShouldDisconnect = true;
}
  int cConsoleApplication::Run()
  {
    bool bIsSuccessfulRun = true;
    bool bIsHandledAlready = false;

    const size_t n = GetArgumentCount();
    if (n == 1) {
      const string_t sArgument0 = GetArgument(0);
      if ((sArgument0 == TEXT("-help")) || (sArgument0 == TEXT("--help"))) {
        bIsHandledAlready = true;
        _PrintHelp();
      } else if ((sArgument0 == TEXT("-version")) || (sArgument0 == TEXT("--version"))) {
        bIsHandledAlready = true;
        PrintVersion();
      }
    }

    if (!bIsHandledAlready) bIsSuccessfulRun = _Run();

    return (bIsSuccessfulRun) ? EXIT_SUCCESS : EXIT_FAILURE;
  }
Exemple #6
0
void
VUView::AttachedToWindow()
{
	SetViewColor(B_TRANSPARENT_COLOR);
	_Run();
}
 /* Run() processes the HTTP request that is encapsulated in the HttpStream obj.
    It is responsible for writing the response into the HttpStream obj
    and returning 0, even in cases were the request failed, e.g., 404.
    A non-0 return value is reserved for extreme cases,
    and will likely result in the caller dropping the connection with the App.
    A valid use case of returning non-0:
    HTTP response header (with Content-Length header) was already sent
    but the response body got truncated in the middle and got short.
  */
 int Run() {
     if (runCalled) return -1;  // FIXME
     runCalled = true;
     return _Run();
 }