PIDL
Creating and setup
Creating the file is simple. Simply create the file in Visual Studio as a txt file, rename the extension to PIDL, and set it up for compilation. Files with the PIDL extension must be set to Custom Build.
Visual Studio solution Viewer
Right-click the PIDL file you created
Properties -> General -> Item Type: Custom Build Tool
PIDL syntax
The PIDL is structured as follows.
When compiling, a namespace is created and the Stub and Proxy Class are placed within this namespace. All RMI functions have a unique ID, and this value is given by adding +1 from the ‘starting value of the message's ID’. However, ID between 0 and 1,300 and ID above 63,000 are used in ProudNet internal messages, so you must use other numbers.
How to use the generated Proxy & Stub file
When you run PIDL, it will generate six files as shown below.
PIDLfile name_Common.Cpp
PIDLfile name_Common.h
PIDLfile name_proxy.Cpp
PIDLfile name_proxy.h
PIDLfile name_stub.Cpp
PIDLfile name_stub.h
For C#, this will create 3 files as shown below.
PIDLfile name_common.cs
PIDLfile name_proxy.cs
PIDLfile name_stub.cs
It is convenient to #include each h file in the header and each cpp file in the cpp file, except for the Common file. You can include the .h and .cpp files in your project, but be aware that the files change frequently due to the use of Custom Build. The generated RMI function automatically adds two parameters in addition to the variables you define.
- Attach a proxy to a client and server
You must first create a Proxy instance of the PIDL compilation output and then register the instance with either Proud.CNetClient or Proud.CNetServer. Clients and servers inherit from Proud.IRmiHost and can register a proxy with it via the method AttachProxy. Each client or server can attach more than one Proxy. However, the range of message IDs must not overlap.
Similarly in C#, you can use the AttachProxy function found in NetServer and NetClient.
For example, if you have TestA.Proxy and TestB.Proxy attached to a single CNetClient, and you declare the first message ID of TestA to be 2,100 and the first message ID of TestB to be 2,200, if the number of RMI functions declared in TestA is 200, the message ID assigned to TestA will be between 2,100 and 2,300, causing the message IDs of TestB to overlap. If the message IDs of the attached proxies overlap, an exception is thrown.
- Attach a stub to a client and server
The Stub instance of the PIDL compilation result has the RMI functions to be executed by messages received over the network as virtual function. When developing, you must inherit this Stub class and override the RMI functions.
In C#, you can create and use the Stub object directly without any overrides.
For the convenience of C++ developers, the PIDL compiler generates the following types of macros, packaged with RMI function names and parameters.
- Order of macro
Clients and servers inherit from Proud.IRmiHost and can register a stub via the method Proud.IRmiHost.AttachStub in it. As with proxies, more than one stub can be attached as long as the message IDs do not overlap.
- Option Class for Communication
It is convenient to use variables declared as internal static.
The most commonly used options are pre-built as Static. You can create your own options to suit your needs.
m_reliability: Selecting Reliable & Unreliable communication methods m_encryptMode: Whether to encrypt (there are three options, depending on speed and security) m_compressMode: Whether to compress
In C#, use a variable defined with the same name.
Usage
Last updated