Making a PIDL file

In order to use Remote Method Invocation(RMI) from ProudNet, you need to create a file with extension PIDL.

PIDL file is a source file that defines messages being exchanged between hosts. When you compile this PIDL file, proxy and stub will get generated. We are going to include these proxy and stub in host program. More details on proxy and stub can be found from Remote Method Invocation.

The basic format of using PIDL file is as followed.

Warning!! Do not use the value between 0 and 1300 & 60000 and 70000 as the first ID value of a message. It already used for ID parameter of ProudNet internal PIDL. If message ID is the same, exception will occur from AttachProxy and AttachStub function.

global <NameSpace> <The first ID value of message>
{
([Characteristic declaration]) <Function declaration> ( [in] Function parameter, ... );
}

Here are the detailed descriptions for above.

  • NameSpace: It's a name of C++ namespace that proxy and stub module get when they are generated by compiling PIDL file. ProudNet can use more 2 of proxy and stub simultaneously but to avoid any conflict they need namespace. For instance, if you declare as LobbyC2S, it would refer to ‘declare server call RMI of Client -> Server from game lobby'.
  • The first ID value of message : When RMIS are called, each RMI converts to network message, which contains ID value in their header. This ID is called the first ID value of message. One thing you need to be careful about is that since there can be several proxy and stub, the range of each message ID must not overwrap. Please refer to The range of message for RMI for more details.
  • Characteristic declaration : Please refer to below.
  • Function declaration : Name of RMI function
  • Function Parameter : It's similar to C++ function declaration. You must declare [in] first. Parameters can allow declarations as followed, except pointer type.
    int a
    std::vector<int> b
    CString c
    Function parameter can use not only the basic type such as int, but also object defined by developer. Please refer to marshaling for more details.

Example for PIDL file is as followed.

global LobbyC2S 5000 // Message ID starts from 5000
{
[encrypted] Logon([in] CString name,[in] CString password); // ID=5001
RequestRoomList([in] int pageNumber); // ID=5002
Chat([in] CString name); // ID=5003
}

Reference