[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Moss-devel] CVS: moss/rmc/src/Client Makefile.am,NONE,1.1 RmcClient.cxx
From: |
Alexander Feder <address@hidden> |
Subject: |
[Moss-devel] CVS: moss/rmc/src/Client Makefile.am,NONE,1.1 RmcClient.cxx,NONE,1.1 |
Date: |
Sun, 23 Jun 2002 09:27:51 -0400 |
Update of /cvsroot/moss/moss/rmc/src/Client
In directory subversions:/tmp/cvs-serv2212/src/Client
Added Files:
Makefile.am RmcClient.cxx
Log Message:
added rmc
--- NEW FILE ---
noinst_LIBRARIES = libRmcClient.a
INCLUDES=-I../../include
CFLAGS=-D_REENTRANT
libRmcClient_a_SOURCES=RmcClient.cxx
#libRmcClient_a_LIBADD=../family/libFamily.la
--- NEW FILE ---
/***************************************************************************
RmcClient.cxx
-------------------
begin : Sun Jun 17 2001
copyright : (C) 2001 by Manfred Morgner
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. *
* *
***************************************************************************
*
* Client side RMC.2 Helper class for remote connection and transport
*
*/
#include "generic.h"
#include "RmcClient.h"
#ifdef WIN32
#else
#include <dlfcn.h>
#endif
using namespace rmc;
/***************************************************************************
*
* Construction/Destruction
*
*/
CRmcClient::CRmcClient(const string &rsConfigFile)
{
Initialize();
// a initial configuration file?
if (rsConfigFile.length() > 0)
{
// we accept the given filename only, if we are able to handle it
if ( ChangeConfiguration(rsConfigFile) == true )
{
m_sConfigFile = rsConfigFile;
} // if ( ChangeConfiguration(sConfigFile) )
} // if (sConfigFile.length() > 0)
} // CRmcClient::CRmcClient(const string &sComputer)
CRmcClient::~CRmcClient()
{
TRACE("[RmcClient Destructor]\n")
ObjectRelease();
} // CRmcClient::~CRmcClient()
/***************************************************************************
*
* public Methods
*
*/
// configures the transport for access to the remote system
// the transport may or may not connect immediately to this
// system - we don't know, but also don't expect that the
// transport do it. the transport may do it for his own purpose
TRmcResult CRmcClient::RemoteSystemConfig(const string& sComputer,
const string& sLogin,
const string& sPassword)
{
if (m_poTransport == 0)
{
return RMC_E_NO_TRANSPORT;
} // if (m_poTransport == 0)
m_poTransport->RemoteSystemConfig(sComputer, sLogin, sPassword);
return RMC_SUCCESS;
} // LONG CRmcClient::RemoteSystemConfig(const string& sComputer,...
// at this point we generate a remote object (stub object), that
// is our representative on the server side. this (remote) object
// is our private object we will work with. if the server is trusted
// we an expect, that the remote object is for exclusive use for the
// local object it was instanciated for.
TRmcResult CRmcClient::ObjectConnect(TRmcClass nClass)
{
TRACE("object connect\n");
// if have no class for which we working for, we don't
// need to try to connect to any server
if (nClass == NO_CLASS)
{
TRACE("\taborting: no class given\n")
return RMC_E_NO_CLASS;
} // if (m_nClass == NO_CLASS)
// if we don't have a transport initialized, we cannot
// instanciate any remote object - so we leave without
// doing anything. this call any any subsequent RmcCall-calls
// will return RMC_E_NO_TRANSPORT. this is better than
// setting any result value, because we don't have to
// care about the connection state. and this is best for
// networked interfaces, because networked states are
// able to change immediately without any action from
// our own part of the system
if (m_poTransport == 0)
{
TRACE("\taborting: no transport loaded\n")
return RMC_E_NO_TRANSPORT;
} // if (m_poTransport == 0)
// the class is to translate, because it is to recgonize
// on the server side and it's an IN-value.
nClass = htonl ( nClass );
// we ensure, we have defined values in our OUT-variables
m_nObject = NO_OBJECT;
m_nVisum = NO_VISUM;
// m_nObject and m_nVisum are no point of "host2network"
// tranlation, because this values are abstract and related
// to the specific server we asked for the remote object
// these values don't have any meaning for the client side
// or any other server
TRmcResult nTrnResult = m_poTransport->RmcConnect(nClass, m_nObject,
m_nVisum);
// if we got an object ID, we have an object on the other server side
// NO_OBJECT is never a valid object-ID
if (m_nObject != NO_OBJECT)
{
// we have a stub
m_bConnected = true;
// the worker class was accepted
m_nClass = nClass;
} // if ( (m_nObject != NO_OBJECT) && (m_nVisum != NO_VISUM) )
// this value means, we have a remote object on the server side
// but I believe, this value is a mistake of me, because we don't
// need to know this state. saving this state is dangeriouse
// because it may lead to wrong assumtions - let me think about
// this until the next release
m_bConnected = true;
return nTrnResult;
} // TRmcResult CRmcClient::ObjectConnect(TRmcClass nClass)
// Call a remote methode
TRmcResult CRmcClient::Call(TRmcMethode nMethode,
TRmcSize &rnSize,
TRmcData *&rpcData)
{
TRACE("call\n");
// if have no server object on the server side, we don't
// need to try to connect to any server
if (m_nObject == NO_OBJECT)
{
TRACE("\taborting: no stub object\n")
return RMC_E_NO_OBJECT;
} // if (m_nClass == NO_CLASS)
// if we don't have an transport loaded we simply return
// the matching error state. any caller has to be able to
// correctly react on unsuccessfull network calls, because
// each network call may fail without any failure in the
// application code
if (m_poTransport == 0)
{
return RMC_E_NO_TRANSPORT;
} // if (m_poTransport == 0)
// the current visum, we haven't to keep the old one
// there is one point where the visum can be changed
// this is on the server side. so - IF the visum
// becomes changed during the remote call, this change
// is for real - the server expects the new visum with
// the following call.
// TRmcVisum nVisum = m_nVisum;
// the size and the methode-id to call are both values for
// interpretation on the server side, thats why we need a
// hots2network translation for them
rnSize = htonl ( rnSize );
nMethode = htonl ( nMethode );
// m_nObject and m_nVisum may change after the call
TRmcResult nTrnResult = m_poTransport->RmcCall(m_nObject, m_nVisum, nMethode,
rnSize, rpcData, m_nLastResult);
// nTrnResult is the "transport result code" given by the
// transport. this is a local issue.
// nTrnResult = ntohl ( nTrnResult );
// nRmcResult is a value, coming in from the server and is
// be interpreted on the client side, that's why we need it
// to be retranslated
m_nLastResult = ntohl ( m_nLastResult );
// as before the call, we have to retranslate the size
// of the returning buffer to be able to use this value in
// the remote call wrapper methods
rnSize = ntohl ( rnSize );
// ok, the tranport may gone wrong, but at this
// point, this has no meaning for us
/*
if (nTrnResult == TRANSPORT_SUCCESS)
{
// if the server changed the visum, we have to change it too
m_nVisum = nVisum;
if (nRmcResult == RMC_SUCCESS)
{
// ...
} // if (rnRmcResult == RMC_SUCCESS)
} // if (nTrnResult == TRANSPORT_SUCCESS)
*/
return nTrnResult;
} // TRmcResult CRmcClient::Call(TRmcMethode nMethode,
// if we leave the server, we have to remove our stub object
// from the server. the server may have other methods killing
// our object, but because we are nice guys, we do it by ourself
TRmcResult CRmcClient::ObjectRelease()
{
TRACE("object release\n");
// if have no server object on the server side, we don't
// need to try to release anything on any server
if (m_nObject == NO_OBJECT)
{
TRACE("\taborting: no stub object\n")
return RMC_E_NO_OBJECT;
} // if (m_nClass == NO_CLASS)
// without any transport, we can call out server
// to do anything - and we may believe, that there
// is nothings to release
if (m_poTransport == 0)
{
return RMC_E_NO_TRANSPORT;
} // if (m_poTransport == 0)
// we don't need to care about this call, the server makes it right
TTransResult nTrnResult = m_poTransport->RmcRelease(m_nObject, m_nVisum);
// nTrnResult is a local code
// nTrnResult = ntohl ( nTrnResult );
TRACE("Transport finished..\n");
// ??
if (nTrnResult == TRANSPORT_SUCCESS)
{
// ok, we assume, the server released our stub
m_nObject = NO_OBJECT;
m_nVisum = NO_VISUM;
} // if (nTrnResult == TRANSPORT_SUCCESS)
// we are not connected anymore, even if there is
// a stub object on the server for us
// "conected" in this case means: we have a stub object
// it does no matter for networking state!
m_bConnected = false;
// we keep the transport in our hands, to reconnect
// to any other server after this call, there is
// no reason to disable networking after releasing
// one of our remote objects (stubs)
// m_fnGetTransport = 0;
TRACE("objectrelease finished..\n")
return RMC_SUCCESS;
} // TRmcResult CRmcClient::ObjectRelease()
/***************************************************************************
*
* protected Methods
*
*/
// simple niitialisation for our object. this methode is called
// from the constructor and does nothings to prevent memory leaks
// if anythings is allocated dynamically.
void CRmcClient::Initialize()
{
m_bConnected = false;
m_nLastResult = 0;
m_nClass = NO_CLASS;
m_nObject = NO_OBJECT;
m_nVisum = NO_VISUM;
// the transport function pointers
m_fnGetTransport = 0;
// automaticall initialized
// m_sConfigFile
} // void CRmcClient::Initialize()
// we (re)configure the transport and other generic properties
// for the object - from an configuration file.
bool CRmcClient::ChangeConfiguration(const string& rsConfigFile)
{
// anyone will change the transport, this means:
// he doesn't need the old transport anymore
// it does no matter if there is an entry or not, the
// current entry (if any) lost his meaning - even if
// it is the same as the new one
m_poTransport = 0;
#ifdef WIN32
m_oLibTransport.FilenameSet (
"./../../../Transport/Socket/Client/Debug/RmcTLClientSocket.dll" );
#else
# ifdef _DEBUG
m_oLibTransport.FilenameSet (
"./../../../Transport/Socket/.libs/libRMCTransportClientSocket.so" );
# else
m_oLibTransport.FilenameSet ( "libRMCTransportClientSocket.so" );
# endif
#endif
// we try to get the address of the function that will give us the
// transport interface
m_fnGetTransport = (pfnGetTransport) m_oLibTransport.FunctionGet (
"GetTransport" );
// may be, anything is wrong
if (m_fnGetTransport == 0)
{
TRACE("ERROR: Couldn't find function export 'GetTransport'\n")
// m_poTransport is "0" from the start of the function
// we only have to leave with "non success" as result
// there is nothings to do for us
return false;
} // if (m_fnGetTransport == 0)
m_poTransport = m_fnGetTransport();
return m_oLibTransport.IsValid ();
} // bool CRmcClient::ChangeConfiguration(const string& rsConfigFile)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Moss-devel] CVS: moss/rmc/src/Client Makefile.am,NONE,1.1 RmcClient.cxx,NONE,1.1,
Alexander Feder <address@hidden> <=
- Prev by Date:
[Moss-devel] CVS: moss/rmc/src/Demos Makefile.am,NONE,1.1
- Next by Date:
[Moss-devel] CVS: moss/rmc/src/Demos/Chat Chat.rmc,NONE,1.1 Makefile.am,NONE,1.1
- Previous by thread:
[Moss-devel] CVS: moss/rmc/src/Demos Makefile.am,NONE,1.1
- Next by thread:
[Moss-devel] CVS: moss/rmc/src/Demos/Chat Chat.rmc,NONE,1.1 Makefile.am,NONE,1.1
- Index(es):