///收到消息
int CwxMqInnerDispHandler::recvMessage() {
  if (CwxMqPoco::MSG_TYPE_INNER_SYNC_REPORT == m_header.getMsgType()) {
    return recvReport(m_tss);
  } else if (CwxMqPoco::MSG_TYPE_SYNC_SESSION_REPORT == m_header.getMsgType()) {
    return recvNewConnection(m_tss);
  } else if (CwxMqPoco::MSG_TYPE_SYNC_DATA_REPLY == m_header.getMsgType()) {
    return recvReply(m_tss);
  } else if (CwxMqPoco::MSG_TYPE_SYNC_DATA_CHUNK_REPLY == m_header.getMsgType()) {
      return recvReply(m_tss);
  }
  ///直接关闭连接
  CWX_ERROR(("Recv invalid msg type:%u from host:%s:%u, close connection.", m_header.getMsgType(), m_strPeerHost.c_str(), m_unPeerPort));
  return -1;
}
Beispiel #2
0
int InsertCommand::execute( ossSocket & sock, std::vector<std::string> & argVec )
{
   int rc = EDB_OK;
   if( argVec.size() <1 )
   {
      return getError(EDB_INSERT_INVALID_ARGUMENT);
   }
   _jsonString = argVec[0];
     if( !sock.isConnected() )
   {
      return getError(EDB_SOCK_NOT_CONNECT);
   }

   rc = sendOrder( sock, msgBuildInsert );
   PD_RC_CHECK ( rc, PDERROR, "Failed to send order, rc = %d", rc ) ;

   rc = recvReply( sock );
   PD_RC_CHECK ( rc, PDERROR, "Failed to receive reply, rc = %d", rc ) ;
   rc = handleReply();
   PD_RC_CHECK ( rc, PDERROR, "Failed to receive reply, rc = %d", rc ) ;
done :
   return rc;
error :
   goto done ;
}
Beispiel #3
0
int
main(int argc, char** argv)
{
    DBusConnection* bus = NULL;
    DBusMessage* msg = NULL;
    DBusError error;
    DBusPendingCall* pending;

    dbus_error_init(&error);

    printf("Connecting to Session D-Bus\n");
    bus = dbus_bus_get(DBUS_BUS_SESSION, &error);
    terminateOnError("Failed to open Session bus\n", &error);
    assert(bus != NULL);

    printf("Creating a message object\n");
    msg = dbus_message_new_method_call(
            NOTIFY_TARGET,
            NOTIFY_OBJ_PATH,
            NOTIFY_INTERFACE,
            NOTIFY_METHOD);

    assert(msg != NULL);

    printf("Appending arguments to the message\n");
    fillArgs(msg);

#ifndef WAIT_FOR_REPLY
    dbus_message_set_no_reply(msg, TRUE);

    printf("Adding message to client send-queue\n");
    dbus_connection_send(bus, msg, NULL);

    printf("Waiting for send-queue to be send out\n");
    dbus_connection_flush(bus);

    printf("Cleaning up message\n");
    dbus_message_unref(msg);
#else
    printf("Adding message to client send-queue\n");

    dbus_connection_send_with_reply(bus, msg, &pending, -1);

    printf("Waiting for send-queue to be send out\n");
    dbus_connection_flush(bus);

    printf("Cleaning up message\n");
    dbus_message_unref(msg);

    recvReply(pending);
#endif

    printf("Cleaning up connection\n");
    dbus_connection_unref(bus);
    return 0;
}
Beispiel #4
0
static asynStatus executeCommand(Port* pport,asynUser* pasynUser)
{
    int i;
    asynStatus sts;

    asynPrint(pasynUser,ASYN_TRACE_FLOW,"drvLove::executeCommand\n");
    pasynUser->timeout = K_COMTMO;

    for( i = 0; i < 3; ++i )
    {
        epicsThreadSleep( K_TUNE );

        sts = sendCommand(pport,pasynUser,i);
        if( ISOK(sts) )
            asynPrint(pasynUser,ASYN_TRACEIO_FILTER,"drvLove::executeCommand write \"%s\"\n",pport->outMsg);
        else
        {
            if( sts == asynTimeout )
            {
                asynPrint(pasynUser,ASYN_TRACE_ERROR,"drvLove::executeCommand write timeout, retrying\n");
                continue;
            }

            asynPrint(pasynUser,ASYN_TRACE_ERROR,"drvLove::executeCommand write failure - Sent \"%s\" \n",pport->outMsg);
            return( sts );
        }

        sts = recvReply(pport,pasynUser,pport->inpMsg,sizeof(pport->inpMsg));
        if( ISOK(sts) )
            asynPrint(pasynUser,ASYN_TRACEIO_FILTER,"drvLove::executeCommand read \"%s\"\n",pport->inpMsg);
        else
        {
            if( sts == asynTimeout )
            {
                asynPrint(pasynUser,ASYN_TRACE_ERROR,"drvLove::executeCommand read timeout, retrying\n");
                continue;
            }

            asynPrint(pasynUser,ASYN_TRACE_ERROR,"drvLove::executeCommand read failure - Sent \"%s\" Rcvd \"%s\" \n",pport->outMsg,pport->inpMsg);
            return( sts );
        }

        return( asynSuccess );
    }

    asynPrint(pasynUser,ASYN_TRACE_ERROR,"drvLove::executeCommand retries exceeded\n");
    return( asynError );
}
Beispiel #5
0
int SnapshotCommand::execute( ossSocket & sock, std::vector<std::string> &argVec)
{
   int rc = EDB_OK;
   if( !sock.isConnected() )
   {
      return getError(EDB_SOCK_NOT_CONNECT);
   }

   rc = sendOrder( sock, OP_SNAPSHOT );
   PD_RC_CHECK ( rc, PDERROR, "Failed to send order, rc = %d", rc);
   rc = recvReply( sock );
   PD_RC_CHECK ( rc, PDERROR, "Failed to receive reply, rc = %d", rc);
   rc = handleReply();
   PD_RC_CHECK ( rc, PDERROR, "Failed to receive reply, rc = %d", rc);
done :
   return rc;
error :
   goto done ;
}