示例#1
0
  void RequestApplication::fromApp( const FIX::Message& message, const FIX::SessionID& sessionId )
    throw( FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::UnsupportedMessageType )
  {
#ifndef NDEBUG
    if ( message.getHeader().getField( FIX::FIELD::SenderCompID ).find( orderGeneratorId ) == std::string::npos )
    {
      dismantleFIX( "INBOUND", message.toString() ) ;
    }
#endif

    try
    {
      crack( message, sessionId ); 
    }
    catch( std::exception &e )
    {
      FIX42::Reject fixReject;
      fixReject.setField( FIX::FIELD::RefSeqNum, message.getHeader().getField( FIX::FIELD::MsgSeqNum ) ) ;
      fixReject.setField( FIX::FIELD::RefMsgType, message.getHeader().getField( FIX::FIELD::MsgType ) ) ;
      // fixReject.setField( FIX::FIELD::RefTagID,
      fixReject.setField( FIX::FIELD::Text, e.what() ) ;
      // fixReject.setField( FIX::FIELD::SessionRejectReason ( sessionRejectReason ) ) ;
    
      try
      {
        FIX::Session::sendToTarget ( fixReject, sessionId ) ;

      }
      catch ( FIX::SessionNotFound &e )
      {
        std::cout << "Error on Sending execution report " << e.what() << std::endl ;
      }
    }
  }
void FixApplication::toAdmin( FIX::Message& message, const FIX::SessionID& sessionID )
{
	if(strcmp(message.getHeader().getField(35).c_str(), "A") == 0 && mCredentials != NULL) {
		message.setField(553, mCredentials->username.c_str());
		message.setField(554, mCredentials->password.c_str());
	}

	FixApplication::dispatchEvent(std::string("toAdmin"), message, sessionID);
}
示例#3
0
  void RequestApplication::toApp( FIX::Message&message, const FIX::SessionID& )
    throw( FIX::DoNotSend ) 
  {
#ifndef NDEBUG
    if(  message.getHeader().getField( FIX::FIELD::TargetCompID ).find( orderGeneratorId ) == std::string::npos  )
    {
      dismantleFIX( "OUTBOUND", message.toString() ) ;
    }
#endif
  }
void FixApplication::fromAdmin( const FIX::Message& message, const FIX::SessionID& sessionID )
	throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::RejectLogon)
{
	FixApplication::dispatchEvent(std::string("fromAdmin"), message, sessionID);

	if(strcmp(message.getHeader().getField(35).c_str(), "A") == 0 && mLoginProvider != NULL) {
	  fix_event_t *data = new fix_event_t;
	  data->eventName = std::string("onLogonAttempt");
	  data->callbacks = mCallbacks;
	  data->sessionId = &sessionID;
	  data->message = new FIX::Message(message);
	  data->logon = mLoginProvider->getLogon();

	  FixLoginResponse* logonResponse = new FixLoginResponse();
	  data->logonResponse = logonResponse;

	  Dispatcher::getInstance().dispatch(data);

	  while(!logonResponse->getIsFinished()) {
	  }

	  if(!logonResponse->getIsLoggedOn()) {
		  //delete logonResponse;
		  throw FIX::RejectLogon();
	  }

	  //delete logonResponse;
  }

}
void Application::toApp( FIX::Message& message, const FIX::SessionID& sessionID )
throw( FIX::DoNotSend )
{
  try
  {
    FIX::PossDupFlag possDupFlag;
    message.getHeader().getField( possDupFlag );
    if ( possDupFlag ) throw FIX::DoNotSend();
  }
  catch ( FIX::FieldNotFound& ) {}

  //std::cout << std::endl << "OUT: " << message.toXML()  << std::endl;
}
void Application::InsertSecurityListRequest( const FIX::Message & message )
{
  /* 320  */ FIX::FieldBase reqID( FIX::FIELD::SecurityReqID, "0" );
  /* 320  */ message.getFieldIfSet( reqID );

  std::ostringstream s;
  s << "INSERT INTO `security_list_request` " <<
    "( `ReqID` ) " <<
    "VALUES " <<
    "( '" << reqID << "' )";
  
  FIX::MySQLQuery q( s.str() );
  m_sql->execute( q );
}
示例#7
0
 void toAdmin( FIX::Message& message, const SessionID& )
 {
   MsgType msgType;
   message.getHeader().getField( msgType );
   switch ( msgType.getValue() [ 0 ] )
   {
     case 'A':
     toLogon++; sentLogon = message; break;
     case '2':
     toResendRequest++;
     sentResendRequest = message; break;
     case '0':
     toHeartbeat++; sentHeartbeat = message; break;
     case '5':
     toLogout++; break;
     case '3':
     toReject++; break;
     case '4':
     toSequenceReset++; break;
   }
 }