Пример #1
0
bool CCNetDelegate::connect()
{
	if( m_eStatus != eSocketConnected && m_eStatus != eSocketConnecting )
	{
        m_wRecvSize = 0;
        m_cbSendRound = 0;
        m_cbRecvRound = 0;
        m_dwSendTickCount = 0;
        m_dwRecvTickCount = 0;
        m_dwSendPacketCount = 0;
        m_dwRecvPacketCount = 0;
        
		m_oSocket.setInetAddress(m_oInetAddress);
		if( m_oSocket.ccConnect() )
		{
			registerScheduler();
			m_eStatus = eSocketConnecting;
			return true;
		}
		else
		{
			m_oSocket.ccClose();
			m_eStatus = eSocketConnectFailed;
			onExceptionCaught(eSocketConnectFailed);
		}
	}
	return false;
}
Пример #2
0
bool TKeyhoteeApplication::notify(QObject* receiver, QEvent* e)
{
  try
  {
    return QApplication::notify(receiver, e);
  }
  catch (const fc::exception& e)
  {
    onExceptionCaught(e);
  }
  catch(...)
  {
    onUnknownExceptionCaught();
  }

  return true;
}
Пример #3
0
bool CCNetDelegate::connect()
{
	if( m_eStatus != eSocketConnected && m_eStatus != eSocketConnecting )
	{
		m_oSocket.setInetAddress(m_oInetAddress);
		if( m_oSocket.ccConnect() )
		{
			registerScheduler();
			m_eStatus = eSocketConnecting;
			return true;
		}
		else
		{
			m_oSocket.ccClose();
			m_eStatus = eSocketConnectFailed;
			onExceptionCaught(eSocketConnectFailed);
		}
	}
	return false;
}
Пример #4
0
int TKeyhoteeApplication::run()
{
  int exitCode = TExitStatus::SUCCESS;
  
#ifndef WIN32
  signal(SIGSEGV, linuxSignalHandler);
#endif ///WIN32

  try
  {
    setOrganizationDomain("invictus-innovations.com");
    setOrganizationName("Invictus Innovations, Inc");
    setApplicationName(APP_NAME);

    startup();

    connect(this, &QApplication::aboutToQuit, [=](){ bts::application::instance()->quit(); });

    QTimer fc_exec;
    QObject::connect(&fc_exec, &QTimer::timeout, 
                     [](){ fc::usleep(fc::microseconds(30 * 1000) ); }
                    );
    fc_exec.start(30);

    /// increment any QT specific status by last our one to avoid conflicts.
    _exit_status = LAST_EXIT_STATUS + (unsigned int)exec();
  }
  catch(const fc::exception& e)
  {
    onExceptionCaught(e);
  }

  catch(...)
  {
    onUnknownExceptionCaught();
  }

  return _exit_status;
}
Пример #5
0
void CCNetDelegate::runSchedule(float dt)
{
	switch( m_eStatus )
	{
	case eSocketConnecting:
		{
			switch( m_oSocket.ccIsConnected() )
			{
			case eSocketConnected:
				{
					m_eStatus = eSocketConnected;
					onConnected();
				}
				break;
			case eSocketConnectFailed:
				{
					unregisterScheduler();
                    m_oSocket.ccClose();
					m_eStatus = eSocketConnectFailed;
					onExceptionCaught(eSocketConnectFailed);
				}
				break;
			case eSocketConnecting:
				{
					if( m_fConnectingDuration > m_fSoTimeout )
					{
						unregisterScheduler();
						m_oSocket.ccDisconnect();
						m_eStatus = eSocketDisconnected;
						onConnectTimeout();
						m_fConnectingDuration = 0.0f;
					}
					else
					{
						m_fConnectingDuration += dt;
					}
				}
				break;
			default:
				break;
			}
		}
		break;
	case eSocketConnected:
		{
#if HANDLE_ON_SINGLE_FRAME
			while( m_oSocket.ccIsReadable() )
#else
			if( m_oSocket.ccIsReadable() )
#endif
			{
				if( this->runRead() ) return;
			}

#if HANDLE_ON_SINGLE_FRAME
			while( m_oSocket.ccIsWritable() && !m_lSendBuffers.empty() )
#else
			if( m_oSocket.ccIsWritable() && !m_lSendBuffers.empty() )
#endif
			{
				if( this->runWrite() ) return;
			}
		}
		break;
	default:
		break;
	}	
}