Running a Dynamic Server

To run the Network application, you have to start a dynamic server like the one you can compile in the dynserver demonstration. This dynamic server must read the model file converted to XML format, as well as the script files you wrote in section Defining the Behavior of the Application.

The main function of a dynamic server should be the following:

#include <ilserver/mvtcp/tcpmvproc.h>

#include <ilserver/dynmvsvr.h>

#include <ilserver/scriptmgr.h>

 

int main(int argc, char* argv[])

{

IlsSetLocaleOnce();

 

if (!IlsTcpMvProcess::Initialize(argc, argv))

{

IlsFatalError() << "Initialization of the communication layer failed"

<< IlsEOM;

}

 

if (!IlsDynMvServer::Initialize(argc,argv,

IlsMvServer::ILS_THREADED_DEFAULT, IlsTrue))

{

IlsFatalError() << "Initialization of server failed" << IlsEOM;

IlsExit(1);

}

 

// execute startup script

IlsScriptManager::OnLoad(argc, argv);

IlsMvServer::Notify();

 

ILS_COUT << "Dynamic Server is ready" << ILS_ENDL;

 

IlsMvServer::Run();

return 0;

} // main

Instead of initializing a standard dynamic view server, we start a dynamic server using the IlsDynMvServer class. This class initializes the dynamic modeling capabilities and parses some specific command-line arguments to load the definition of a dynamic model and a script file.

The IlsScriptManager class is used to invoke the startup method OnLoad.

Note that a notification cycle is started after execution of the OnLoad function to notify existing views, if necessary.

To convert the model file to XMI format, Server provides a contribution, xmigen to convert the model file saved by Microsoft Visual Modeler (.mdl files) to XMI format (.xml files). This contribution is available only for Windows® platforms.

The command line to invoke xmigen is the following:

xmigen.exe network.mdl

This contribution generates a network.xml file which follows the XMI 1.0 specification.

The command line to start the dynamic server is the following:

dynserver -ilsn dyn -ilsm network.xml -ilsj network.ilj