Fovia's C++ Server API
Public Member Functions | List of all members
IHdrcServer Struct Referenceabstract
Inheritance diagram for IHdrcServer:
IRoot

Public Member Functions

virtual signed int AcceptConnection (void **s, signed int port, void *params, signed int *bLocalConnection)=0
 
virtual signed int AskInterface (const BGUID *piid, struct IRoot **ppr)=0
 
virtual signed int ConnectToServer (void **s, char *host, signed int port, signed int *bLocalConnection)=0
 
virtual signed int CreateClientStream (void *s, ILogger *pLogger, ISimpleStream **pp)=0
 
virtual signed int CreateClientStreamEx (void *s, ILogger *pLogger, ISimpleStream **pp, signed int bLocalConnection)=0
 
virtual signed int CreateServerStream (void *s, ISimpleStream **pp)=0
 
virtual signed int CreateServerStreamEx (void *s, ISimpleStream **pp, signed int bLocalConnection)=0
 
virtual signed int CreateSession (signed int SessionType, IHdrcSession **pp)=0
 
virtual signed int DecRef ()=0
 
virtual signed int GetSession (signed int Num, IHdrcSession **pps)=0
 
virtual signed int GetSessionNum (signed int *Num)=0
 
virtual signed int GetStream (ENUM_STREAM_CATEGORY Category, ISimpleStream **ppv)=0
 
virtual signed int GetTraceOptions (ENUM_TRACE_OPTIONS *)=0
 
virtual signed int IncRef ()=0
 
virtual signed int Init ()=0
 
virtual signed int RemoveSession (IHdrcSession *pS)=0
 
virtual signed int SetDatasetLoadFunc (ENUM_LOAD_FUNC loadtype, loadfunc *func)=0
 
virtual signed int SetSegmentFunc (ENUM_SEGMENT_FUNC segmenttype, segmentfunc *func)=0
 
virtual signed int SetStream (ENUM_STREAM_CATEGORY Category, ISimpleStream *pv)=0
 
virtual signed int SetTraceOptions (ENUM_TRACE_OPTIONS e)=0
 
virtual signed int Term ()=0
 
virtual signed int WaitForAllSessions ()=0
 
- Public Member Functions inherited from IRoot
template<class T >
signed int AskInterface (T **pp)
 

Detailed Description

Object implementing IHdrcServer is responsible for maintaining a number of Sessions

Member Function Documentation

virtual signed int IHdrcServer::AcceptConnection ( void **  s,
signed int  port,
void *  params,
signed int *  bLocalConnection 
)
pure virtual

Tells the server library to call the transfer plugin's AcceptConnection() function. If the transfer plugin in question does not implement ConnectToServer, then a listening socket will be created on the specified port and this function will return when a connection has been established.

Parameters
sThis will get the address of a structure that describes the connection to the client. If the transfer plugin being used does not implement AcceptConnection, this will get the address of a SOCKET pointer. Otherwise, what is returned here is up to the implementor of the transfer plugin.
portThis is the port that this function should use to listen for a connection. For user written transfer plugins that don't have the concept of a port, they can simply ignore this parameter.
paramsThis is an optional structure that can be used to pass parameters to the transfer plugin. In the case of the Fovia server application, this will be the address of a SOCKET_STREAM_PARAMS that contains the relevant information for connection. Note that the Fovia server application only works with transfer plugins that use SOCKET_STREAM_PARAMS. If you wish to use another method, the server must be implemented by the user of the API.
bLocalConnectionIf the connected client is local to this machine, *bLocalConnection will get H_TRUE. Otherwise, *bLocalConnection will get H_FALSE.
virtual signed int IHdrcServer::AskInterface ( const BGUID piid,
struct IRoot **  ppr 
)
pure virtual

ask object for another interface

Implements IRoot.

virtual signed int IHdrcServer::ConnectToServer ( void **  s,
char *  host,
signed int  port,
signed int *  bLocalConnection 
)
pure virtual

Tells the server library to call the transfer plugin's ConnectToServer() function. Note that this is called internally by the client API's server context when you call ConnectEx() or Connect(). If the transfer plugin in question does not implement ConnectToServer, then a socket will be used to connect to the server.

Parameters
sThis should be filled with the information about the connection to the server. If the plugin that is being used does not implement ConnectToServer, then this will get a the address of a SOCKET pointer. Otherwise, the plugin implementation is free to put any information about the connection here.
hostThe host parameter as it was passed into the server context's Connect() or ConnectEx() function.
portThe port parameter as it was passed into the server context's Connect() or ConnectEx() function.
bLocalConnectionIhis variable will recieve H_TRUE if the connection is to the local machine and H_FALSE if it is not.
virtual signed int IHdrcServer::CreateClientStreamEx ( void *  s,
ILogger *  pLogger,
ISimpleStream **  pp,
signed int  bLocalConnection 
)
pure virtual

Tells the server library to call the transfer plugin's CreateClientStreamEx() function. Note that this is called internally by the client API's server context when you call ConnectEx() or Connect().

Parameters
sThis is the information about the connection to the server. If the current transfer plugin does not implement ConnectToServer(), then this parameter can be treated as a SOCKET. If ConnectToServer() is implemented, this is the pointer that is returned in the s parameter to ConnectToServer().
pLoggerThis is the ILogger interface passed into the server context's Connect() or ConnectEx() functions.
ppThis will receive the address of the ISimpleStream pointer that will be used in all communcation with the server.
bLocalConnectionIf H_TRUE, then the local streaming plugin specified in hdrcopt.ini will be called. If H_FALSE, then the remote streaming plugin will be used. If hdrcopt.ini is not preset, hdrclocalstr is the local streaming plugin and hdrcsockstr is the remote streaming plugin.
virtual signed int IHdrcServer::CreateServerStream ( void *  s,
ISimpleStream **  pp 
)
pure virtual

Deprecated. Use CreateServerStreamEx and specify whether it is a local or remote connection.

virtual signed int IHdrcServer::CreateServerStreamEx ( void *  s,
ISimpleStream **  pp,
signed int  bLocalConnection 
)
pure virtual

CreateServerStreamEx is responsible of loading ISimpleStream class object from a plugin dll. For details on plugin dlls, please look up at writing custom plugin dll documentation.

If there is no custom plugin dll specified, this function loads the default dll which is responsible for making communication over standard sockets.

Example:

SOCKET s = socket(....
CBComPtr<ISimpleStream> piSession = NULL;
piServer->CreateServerStream(&s,&piStream);
Parameters
sThis is the information about the connection to the server. If the current transfer plugin does not implement ConnectToServer(), then this parameter can be treated as a SOCKET. If ConnectToServer() is implemented, this is the pointer that is returned in the s parameter to ConnectToServer().
ppThis will receive the address of the ISimpleStream pointer that will be used in all communcation with the server.
bLocalConnectionIf H_TRUE, then the local streaming plugin specified in hdrcopt.ini will be called. If H_FALSE, then the remote streaming plugin will be used. If hdrcopt.ini is not preset, hdrclocalstr is the local streaming plugin and hdrcsockstr is the remote streaming plugin.
virtual signed int IHdrcServer::CreateSession ( signed int  SessionType,
IHdrcSession **  pp 
)
pure virtual

This function creates session object and returns pointer back. The session object is responsible for maintaing session of a particular cleint. All the requests of the clinet for Fovia's renndering engine are passed through session object. Without session object, no cleint can connect and cannot request for any type of service from the server. Example:

RRESULT hr = S_OK;
CBComPtr<IHdrcSession> piSession = NULL;
CBComPtr<IHdrcServer> piServer = NULL; //declaring IHdrcServer interface pointer
hr = hdrcCreateServer(HDRCSRV_SDK_VERSION, &piServer); //Creating an instance of object implementing IHdrcServer Interface
if(hr == S_OK) //Checking creating of object
hr = piServer->Init(); //Initialize the Server
if(hr == S_OK)
{
hr = piServer->CreateSession(0,&piSession);
}
...
Parameters
SessionTypefor now this session must be set to zero.
ppis a pointer to a IHdrcSession interface pointer (pointer to a pointer **).
virtual signed int IHdrcServer::DecRef ( )
pure virtual

decrements the reference count for the object

Implements IRoot.

virtual signed int IHdrcServer::GetSession ( signed int  Num,
IHdrcSession **  pps 
)
pure virtual

This function returns the session object corrosponding to the session number/count passed. Example:

h_int32 cnt = 2;
CBComPtr<IHdrcSession> piSession = NULL;
piServer->GetSession(cnt,&piSession);
Parameters
Numis an integer.
ppsis a pointer to a IHdrcSession interface pointer (pointer to a pointer **)
virtual signed int IHdrcServer::GetSessionNum ( signed int *  Num)
pure virtual

This function returns the number of sessions running, or in words, it returns the number of clients connected

Example:

h_int32 cnt;
piServer->GetSessionNum(&cnt);
Parameters
Numis a pointer to an integer.
virtual signed int IHdrcServer::GetStream ( ENUM_STREAM_CATEGORY  Category,
ISimpleStream **  ppv 
)
pure virtual

This function allows to get back the stream of specified catagory. It allows the following type of streams

SC_STD_LOG Logging
SC_ERR_LOG Error
SC_IN In
SC_OUT Out
SC_INOUT In/Out (Both)

Example:

CBComPtr<ISimpleStream> piSession = NULL;
piServer->GetStream(SC_STD_LOG,&piStream);
Parameters
Categoryis of enumeration type BCOM_THIS_ ENUM_STREAM_CATEGORY.
ppvis a pointer to a pointer of type ISimpleStream interface.
virtual signed int IHdrcServer::IncRef ( )
pure virtual

increments the reference count for the object

Implements IRoot.

virtual signed int IHdrcServer::Init ( )
pure virtual

This is the entry point into the Server API interface. After the factory method call hdrcCreateServer() This is the first call for internal initialization. Example:

RRESULT hr = S_OK;
CBComPtr<IHdrcServer> piServer = NULL; //declaring IHdrcServer interface pointer
hr = hdrcCreateServer(HDRCSRV_SDK_VERSION, &piServer); //Creating an instance of object implementing IHdrcServer Interface
if(hr == S_OK) //Checking creating of object
hr = piServer->Init(); //Initialize the Server
virtual signed int IHdrcServer::RemoveSession ( IHdrcSession pS)
pure virtual

This function removes the session object. The session object is responsible for maintaing session of a particular cleint. All the requests of the clinet for Fovia's rendering engine are passed through session object. Without session object, client cannot connect.

Example:

RRESULT hr = S_OK;
hr = piServer->RemoveSession(piSession);
Parameters
pSis a pointer to an IHdrcSession object.
virtual signed int IHdrcServer::SetDatasetLoadFunc ( ENUM_LOAD_FUNC  loadtype,
loadfunc *  func 
)
pure virtual

Sets a custom dataset loading function.

Parameters
loadtypeAn interger value cast to the ENUM_LOAD_FUNC type. This value is used to identify the function when called from a client application.
funcA function pointer to the custom loading function implmentation. This function must conform to the loadfunc prototype.
virtual signed int IHdrcServer::SetSegmentFunc ( ENUM_SEGMENT_FUNC  segmenttype,
segmentfunc *  func 
)
pure virtual

Sets a custom segmentation or data analysis function.

Parameters
loadtypeAn interger value cast to the ENUM_SEGMENT_FUNC type. This value is used to identify the function when called from a client application.
funcA function pointer to the custom segmentation or analysis function implmentation. This function must conform to the segmentfunc prototype.
virtual signed int IHdrcServer::SetStream ( ENUM_STREAM_CATEGORY  Category,
ISimpleStream *  pv 
)
pure virtual

This function allows different type of streams to be directed to the given ISimpleStream object It allows the following type of streams

SC_STD_LOG Logging
SC_ERR_LOG Error
SC_IN In
SC_OUT Out
SC_INOUT In/Out (Both)

Example:

piServer->SetStream(SC_STD_LOG,piStream);
Parameters
Categoryis of enumeration type BCOM_THIS_ ENUM_STREAM_CATEGORY.
pvis a pointer to a ISimpleStream interface
virtual signed int IHdrcServer::SetTraceOptions ( ENUM_TRACE_OPTIONS  e)
pure virtual

Set trace options

virtual signed int IHdrcServer::Term ( )
pure virtual

This called is needed to cleanup the server instance allocated data structure. It is highly recommended to for graceful termination. Example:

RRESULT hr = S_OK;
CBComPtr<IHdrcServer> piServer = NULL; //declaring IHdrcServer interface pointer
hr = hdrcCreateServer(HDRCSRV_SDK_VERSION, &piServer); //Creating an instance of object implementing IHdrcServer Interface
if(hr == S_OK) //Checking creating of object
hr = piServer->Init(); //Initialize the Server
...
hr = piServer->Term(); //Terminate the Server
virtual signed int IHdrcServer::WaitForAllSessions ( )
pure virtual

This called is needed to wait on all the sessions to be closed before the server is allowed to terminate. This call is blocking and will return once all the sessions are terminated and related data is released. Before calling Term(), the Server API client must call WaitForAllSessions() to makes sure that there is no session and its related data. If WaitForAllSessions() is called called before application exists, there might not be a graceful exit. If this API is used in a Windows Service, please do not forget to call this function before exit.