ProudNet.Eng
WebsiteProud ConsoleLanguage
  • 🌐ProudNet
    • ProudNet Introduction
    • Download and Install
      • How to verify your ProudNet license
      • AMI
    • Project Settings
      • C++
      • C#
      • Mac Xcode
      • Linux
      • Unity3D
        • iOS Build
      • Unreal Engine 4
      • Running the PIDL Compiler
    • Using ProudNet
      • Server and Client
        • Utilization of Server
        • Utilization of Client
      • RMI
        • Utilization of RMI
      • PIDL
        • Utilization of PIDL
      • Event handling
      • Communication messages
      • P2P Communication
        • Using P2P communication
    • Utilization of ProudNet
      • How to use
      • Tips for performance
    • Using DB in ProudNet
      • DB Cache System ver.2
        • DB Cache Theory and Understanding
        • Install DB Cache and Set Up Network
        • DB Cache Server and Client
        • DB Cache usage and application
          • Utilization of DB Cache
      • ADO API
      • ODBC API
    • ProudNet Utility
  • ProudNet Note
    • Technical Notes
      • Main Loop
      • Setting up a server firewall
      • Encryption and decryption
      • What to do in case of an error
      • List of error messages
      • Synchronizing Character Position
      • Client-Server Communication
      • MiniDump (Error Dump System)
      • [Version 1.6] Server-to-Server LAN Communicator
    • Glossary
    • Sample examples
  • 🌐Proud Service
    • Guide for Console
    • ProudChat
      • Download SDK
        • C++
        • C#
        • Unity3D
        • Unreal Engine 4
      • Features in Console
Powered by GitBook
On this page
  1. ProudNet
  2. Using ProudNet

Event handling

Working with event handlers

ProudNet's event handling is in the delegate pattern.

The client implements it by inheriting from class Proud.INetClientEvent, and the server implements it by inheriting from class Proud.INetServerEvent. After creating instances of the classes you implemented, you need to associate them with Proud.CNetServer.SetEventSink on the server and Proud.CNetClient.SetEventSink on the client.

class MyEvent:public INetClientEvent
{
    virtual void OnJoinServerComplete(...) override 
    { 
        // my event handler
        ...
    }
}
 
MyEvent m_myEvent;
myNetServer->SetEventSink(&m_myEvent); 

If you are using a compiler that supports C++11, you can do more concise programming by using lambda expressions instead of inheriting the class above.

myNetServer->OnJoinServerComplete = [...](...) 
    {
        // my event handler
        ...
    };
myNetServer.OnJoinServerComplete = () =>
    {
        // my event handler
        ...
    };

Typical events that can occur on the server include "receiving a connection from a client" and typical events that occur on the client include "establishing a connection with the server" and "joining a P2P member".

Make sure to Log the Event.

During technical support, the most common problem is that it is difficult to find the cause of the problem because it is not logged. In particular, be sure to log the following events and functions that take errorInfo as a parameter.

  • OnError: Callbacks information about errors or usage issues that occur inside ProudNet.

  • OnWarning: Callback information that is not critical but potentially problematic.

  • OnInformation: Callback information about the internal situation, tracking, etc.

  • OnException: Callback internal Exception error information.

You can easily get information about the problem by using errorInfo -> ToString(); in the parameter errorInfo.

Last updated 1 year ago

See or more information on when you can receive event callbacks from the above process.

🌐
About main loop
Linking event handlers on the client