moss-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Moss-devel] CVS: moss/rmc/src/Transport Makefile.am,NONE,1.1 TransportC


From: Alexander Feder <address@hidden>
Subject: [Moss-devel] CVS: moss/rmc/src/Transport Makefile.am,NONE,1.1 TransportClient.cxx,NONE,1.1 TransportClientHandler.cxx,NONE,1.1 TransportServer.cxx,NONE,1.1
Date: Sun, 23 Jun 2002 09:27:52 -0400

Update of /cvsroot/moss/moss/rmc/src/Transport
In directory subversions:/tmp/cvs-serv2212/src/Transport

Added Files:
        Makefile.am TransportClient.cxx TransportClientHandler.cxx 
        TransportServer.cxx 
Log Message:
added rmc


--- NEW FILE ---
SUBDIRS = . Socket 
noinst_LTLIBRARIES = libRMCTransportServer.la libRMCTransportClient.la 
libRMCTransportClientHandler.la
#lib_LTLIBRARIES = libRMCTransportClientHandler.la

CXXFLAGS = -Wall -g -O2

INCLUDES=-I../../include

libRMCTransportServer_la_LDFLAGS = --export-dynamic
libRMCTransportServer_la_SOURCES = TransportServer.cxx

libRMCTransportClient_la_LDFLAGS = --export-dynamic
libRMCTransportClient_la_SOURCES = TransportClient.cxx

libRMCTransportClientHandler_la_LDFLAGS = --export-dynamic
libRMCTransportClientHandler_la_SOURCES = TransportClientHandler.cxx
#libRMCTransportClientHandler_la_LIBADD = -lpthread ../family/libFamily.la 

--- NEW FILE ---
/***************************************************************************
                           TransportClient.cxx
                           -------------------
    begin                : Thu June 7 2001
    copyright            : (C) 2001 by Alexander Feder
    email                : address@hidden 

 ***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *                                                                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place Suite 330,                                            *
 *   Boston, MA  02111-1307, USA.                                          *
 *                                                                         *
 ***************************************************************************/

#include "generic.h"
#include "Transport/TransportClient.h"


using namespace rmc;

/***************************************************************************
 *
 *  Construction/Destruction
 *
 */

CTransportClient::CTransportClient ( )
  {
  Initialize();
  } // CTransportClient::CTransportClient ( )

CTransportClient::~CTransportClient ( )
  {
  TRACE("CTransportClient Destruktor\n")
  delete m_poTransportBufferClient;
  } // CTransportClient::~CTransportClient ( )

/***************************************************************************
 *
 *  public Methods
 *
 */

LONG CTransportClient::RemoteSystemConfig (const string& sComputer,
                                           const string& sLogin,
                                           const string& sPassword)
  {
  m_sLoginName = sLogin;
  m_sPassword  = sPassword;

  if ( Connect ( ) < 0 )
    {
    TRACE("Failure while trying to connect\n")
    return -1;
    } // if ( CTransportClient::Connect ( ) < 0 )

  return CTransportClient::Authenticate ( );
  } // LONG CTransportClient::RemoteSystemConfig (const string& sComputer,..

TTransResult CTransportClient::RmcConnect ( TRmcClass   nClass,   // IN
                                            TRmcObject &rnObject, //    OUT
                                            TRmcVisum  &rnVisum ) //    OUT
  {
  // a reference that manipulates our m_poTransportBufferClient
  CTransportBufferInterface &oTransportBuffer = *m_poTransportBufferClient;
  TRACE("[Transport RmcConnect]\n")
  oTransportBuffer.IdentSet( RMC_IDENT_CONNECT );
  oTransportBuffer << nClass;
  oTransportBuffer.Send ();

  TTransResult nResult = 0;

  if ( oTransportBuffer.Recv () <= 0 )
    {
    TRACE("\tError!\n")
    return 0;
    } // if ( oTransportBuffer.Recv () <= 0 )

  oTransportBuffer >> nResult;  // cout << "nresult.: " << nResult  << endl;
  oTransportBuffer >> rnObject; // cout << "object..: " << rnObject << endl;
  oTransportBuffer >> rnVisum;  // cout << "visum...; " << rnVisum  << endl;

  m_nLastRmcResult = nResult;
  return nResult;
  } // TTransResult CTransportClient::RmcConnect(TRmcClass nClass,..

TTransResult CTransportClient::RmcCall( TRmcObject   nObject,  // IN
                                        TRmcVisum   &rnVisum,  // IN,OUT
                                        TRmcMethode  nMethode, // IN
                                        TRmcSize    &rnSize,   // IN,OUT
                                        TRmcData   *&rpcData,  // IN,OUT
                                        TRmcResult  &rnResult) //    OUT
  {
  CTransportBufferInterface &oTransportBuffer = *m_poTransportBufferClient;
  TRACE("[Transport RmcCall]\n")
  oTransportBuffer.IdentSet( RMC_IDENT_CALL );
  oTransportBuffer << nObject;  // cout << "object..: " << nObject  << endl;
  oTransportBuffer << rnVisum;  // cout << "visum...: " << rnVisum  << endl;
  oTransportBuffer << nMethode; // cout << "methode.: " << nMethode << endl;
  oTransportBuffer << rnSize;   // cout << "size....: " << rnSize   <<endl;

  oTransportBuffer.Push ( (UCHAR*&) rpcData, ntohl(rnSize) );
  oTransportBuffer.Send ( );

  if ( oTransportBuffer.Recv () <= 0 )
    {
    TRACE("\tError!\n");
    return 0;
    } // if ( oTransportBuffer.Recv () <= 0 )

  oTransportBuffer >> rnVisum;  // cout << rnVisum << endl;
  oTransportBuffer >> rnSize;   // cout << rnSize  << endl;
  if ( rnResult != -1 )
    {
    //oTransportBuffer.Pop ( (UCHAR*&) rpcData, rnSize );
    oTransportBuffer >> (UCHAR*&) rpcData;
    }

  oTransportBuffer >> rnResult;
  // we save the last result for further use
  m_nLastRmcResult = rnResult;
  // the return value is the _transport_ result, not the rmc result
  return TRANSPORT_SUCCESS;
  } // TTransResult CTransportClient::RmcCall(TRmcObject nObject,..

TTransResult CTransportClient::RmcRelease ( TRmcObject nObject, // IN
                                                  TRmcVisum  nVisum ) // IN
  {
  CTransportBufferInterface &oTransportBuffer = *m_poTransportBufferClient;
  TRACE("[Transport RmcRelease]\n")
  oTransportBuffer.IdentSet( RMC_IDENT_RELEASE );
  oTransportBuffer << nObject;
  oTransportBuffer << nVisum;
  oTransportBuffer.Send ( );

  TRmcResult nResult = 0;

  if ( oTransportBuffer.Recv () <= 0 )
    {
    TRACE("Error!\n")
    return 0;
    } // if ( oTransportBuffer.Recv () <= 0 )

  oTransportBuffer >> nResult;

  // we save the last result for further use
  m_nLastRmcResult = nResult;
  TRACE("[RmcRelease] - {END}\n")
  // the return value is the _transport_ result, not the rmc result
  return nResult;
  } // TTransResult CTransportClient::RmcRelease(TRmcObject nObject,..

void CTransportClient::Initialize ( )
  {
  m_poTransportBufferClient = 0;
  // rmc controlling  - nothings happend, so allthings are ok
  m_nLastRmcResult = RMC_SUCCESS;
  } // void CTransportClient::Initialize ( )

/***************************************************************************
 *
 *  protected Methods
 *
 */


LONG CTransportClient::Authenticate ( )
  {
  /*
  cout << "Authenticate..." << endl;
  Write ( (unsigned char*) "halloo", 6 );
  unsigned char* pucTemp;
  LONG lSize = Read ( &pucTemp );
  pucTemp[lSize] = '\0';
  cout << "Uebertragen: [" << lSize << "] - [" << pucTemp << "]" << endl;
  */
  return 0;
  } // LONG CTransportClient::Authenticate ( )


/***************************************************************************
 *
 *  code to remove/modify
 *
 */


--- NEW FILE ---
/***************************************************************************
                        TransportClientHandler.cxx
                           -------------------
    begin                : Fri June 29 2001
    copyright            : (C) 2001 Alexander Feder
    email                : address@hidden
 
 ***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *                                                                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place Suite 330,                                            *
 *   Boston, MA  02111-1307, USA.                                          *
 *                                                                         *
 ***************************************************************************/

#include "Transport/TransportClientHandler.h"

using namespace std;
using namespace rmc;
using namespace family;


CTransportClientHandler ::CTransportClientHandler  ( CTransportBufferInterface* 
poSocketClient, CRmcServer *&rpoRmcServer )
: CThreaded ()
  {
  Initialize();
  m_poSocketClient = poSocketClient;
  m_ppoRmcServer = &rpoRmcServer;
  }

CTransportClientHandler ::~CTransportClientHandler ()
  {
  //nothing done yet
  TRACE("CTransportClientHandler  Destructor\n");
  delete m_poSocketClient;
  TRACE("CTransportClientHandler  Destructor End\n");
  }

void CTransportClientHandler ::Initialize ()
  {
  m_ppoRmcServer   = 0;
  m_poSocketClient = 0;
  }


long CTransportClientHandler::Step ()
  {
  // no longer possible here with FdGet(), but i could include an identifier in
  // the interface for client numbering ( ClientNameGet() )
  //cout << "------[ Selecting client (" << m_poSocketClient->FdGet() << ") 
]------" << endl;
  
  LONG nSize = m_poSocketClient->Recv ( );

  if (nSize <= 0)
    {
    // Removing from active connection set
    TRACE("Ah, a client closed connection\n")
    delete this;
    TRACE("....\n")
    return -1;
    } // if (lSize <= 0)
  
  string sType = m_poSocketClient->IdentGet( );
  //  cout << "[POLL] -> [" << sType << "]" << endl;
  
  if ( sType == RMC_IDENT_CONNECT )
    {
    HandleRmcConnect ();
    return true;
    } // if ( sType == RMC_IDENT_CONNECT )
  if ( sType == RMC_IDENT_CALL )
    {
    HandleRmcCall ();
    return true;
    } // if ( sType == RMC_IDENT_CALL )
  
  if ( sType == RMC_IDENT_RELEASE )
    {
    HandleRmcRelease ();
    return true;
    } // if ( sType == RMC_IDENT_RELEASE )
  
  if ( sType.length() > 0 )
    {
    // ?? somethings went wrong ??
    return false;
    } // if ( sType == RMC_IDENT_RELEASE )

  TRACE("Poll returned false !\n")

  return 0;
  } // if (nSize <= 0)

void CTransportClientHandler ::HandleRmcConnect ()
  {
  TRACE("[RmcConnect]\n")

  // we don't have a server to use for this call
  if ( *m_ppoRmcServer == 0 )
    {
    return;
    } // if ( *m_ppoRmcServer == 0 )
  
  TRmcClass nClass = 0;
  
  // Extract the RTTI
  (*m_poSocketClient) >> nClass;
  
  //  cout << "[RmcConnect] Got nClass - [" << nClass << "]" << endl;
  
  TRmcObject  nObject = 0;
  TRmcVisum   nVisum  = 0;
  TRmcResult  nResult = 0;
  //****************************************
  // OKEY, CALL THE _REAL_ RMCCONNECT NOW! *
  //****************************************
  
  nResult = (*m_ppoRmcServer)->RmcConnect(nClass, nObject, nVisum);

#ifdef _DEBUG
  cout << "RmcConnect ( " << nClass << ", " << nObject << ", " << nVisum << " 
)" << endl;
#endif // _DEBUG

  (*m_poSocketClient) << nResult;
  (*m_poSocketClient) << nObject;
  (*m_poSocketClient) << nVisum;
  (*m_poSocketClient).Send ( );
  
  }

void CTransportClientHandler ::HandleRmcCall ()
  {
  TRACE("[RmcCall]\n")

  // we don't have a server to use for this call
  if ( *m_ppoRmcServer == 0 )
    {
    return;
    } // if ( *m_ppoRmcServer == 0 )
  
  TRmcObject  nObject  = 0;
  TRmcVisum   nVisum   = 0;
  TRmcMethode nMethode = 0;
  TRmcSize    nSize    = 0;
  TRmcData   *pcData   = 0;
  
  (*m_poSocketClient) >> nObject;
  //  cout << "Got Object: [" << nObject << "]" << endl;
  (*m_poSocketClient) >> nVisum;
  //  cout << "Got Visum: [" << nVisum << "]" << endl;
  (*m_poSocketClient) >> nMethode;
  // cout << "Got Methode: [" << nMethode << "]" << endl;
  (*m_poSocketClient) >> nSize;
  //  cout << "Got Size: [" << nSize << "]" << endl;
  //(*m_poSocketClient).Pop ( (UCHAR*&) pcData, nSize );
  (*m_poSocketClient) >> (UCHAR*&) pcData;
  //  cout << "Got Data: [" << (char*) pcData << "]" << endl;
  
  TRmcResult  nResult = 0;
  //*************************************
  // OKEY, CALL THE _REAL_ RMCCALL NOW! *
  //*************************************
  // don't forget to give &pcData
  
  nResult = (*m_ppoRmcServer)->RmcCall(nObject, nVisum, nMethode, nSize, 
pcData);

#ifdef _DEBUG
  cout << "RmcCall ( " << nObject << ", " << nMethode << ", " << nSize << ", " 
<< pcData << ", " << nResult << " )" << endl;
#endif // _DEBUG

  (*m_poSocketClient) << nVisum;
  (*m_poSocketClient) << nSize;
  (*m_poSocketClient).Push ( (UCHAR*) pcData, ntohl(nSize) );
  (*m_poSocketClient) << nResult;
  
  (*m_poSocketClient).Send ( );
  
  }

void CTransportClientHandler ::HandleRmcRelease ()
  {
  TRACE("[RmcRelease]\n")

  // we don't have a server to use for this call
  if ( *m_ppoRmcServer == 0 )
    {
    return;
    } // if ( *m_ppoRmcServer == 0 )

  TRmcObject nObject = 0;
  TRmcVisum  nVisum  = 0;
  
  (*m_poSocketClient) >> nObject;
  (*m_poSocketClient) >> nVisum;
  
  TRmcResult nResult = 0;
  //****************************************
  // OKEY, CALL THE _REAL_ RMCRELEASE NOW! *
  //*****************************************
  
  nResult = (*m_ppoRmcServer)->RmcRelease(nObject, nVisum);

#ifdef _DEBUG
  cout << "RmcRelease ( " << nObject << ", " << nVisum << " )" << endl;
#endif // _DEBUG

  (*m_poSocketClient) << nResult;
  (*m_poSocketClient).Send ( );
  }


--- NEW FILE ---
/***************************************************************************
                           TransportServer.cxx
                           -------------------
    begin                : Thu June 7 2001
    copyright            : (C) 2001 by Alexander Feder
    email                : address@hidden

 ***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *                                                                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place Suite 330,                                            *
 *   Boston, MA  02111-1307, USA.                                          *
 *                                                                         *
 ***************************************************************************/

#include "generic.h"
#include "Transport/TransportServer.h"


using namespace rmc;


/***************************************************************************
 *
 *  Construction/Destruction
 *
 */

CTransportServer::CTransportServer ()
  {
  TRACE("CTransportServer::CTransportServer\n")
  Initialize ( );
  } // CTransportServer::CTransportServer (int nPrt)

CTransportServer::~CTransportServer ( )
  {
  TRACE("CTransportServer Destructor");

  // delete the client and server socket objects
  delete m_poSocketServer;
  // Remove all client connections
  RemoveAllClients();
  } // CTransportServer::~CTransportServer ( )

/***************************************************************************
 *
 *  public Methods
 *
 */

void CTransportServer::RegisterRmcServer ( CRmcServer *poRmcServer )
  {
  TRACE( "INFO: RegisterRmcServer\n")
  m_poRmcServer = poRmcServer;

  WaitForClient();
  } // void CTransportServer::RegisterRmcServer ( . )

/***************************************************************************
 *
 *  protected Methods
 *
 */

void CTransportServer::Initialize ( )
  {
  TRACE("CTransportServer::Initialize\n")
  m_poSocketServer = 0;
  m_poRmcServer    = 0;
  } // void CTransportServer::Initialize ( )

/***************************************************************************
 *
 *  private methods
 *
 */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]