Back to product page

Events property


Reference to event handlers.

Type

P2PEventsStruct structure.

Syntax

  • C++
P2PEventsStruct Events;
The Events() syntax has these parts:
Return valueReturns pointer to internal events structure.

Remarks

To use specific event with devP2P, you must implement your own function that has same declaration as the event, and give a reference to P2PEventsStruct for the function. P2PEventStruct members correspond to events, and default to NULL. Below in code samples is shown how to do it for some events.

This is the declaration of P2PEventsStruct
 
   typedef struct P2PEventsStruct
   {
       void (*StateChange)(CP2P *p2p, States state);
       void (*NewUPNPMapping)(CP2P *p2p, char *ExtAddress, char *IntAddress, int TCPPort, int UDPPort);
       void (*SearchStart)(CP2P *p2p, char *binds);
       void (*SearchDone)(CP2P *p2p, char *peerName, char *peerXML, char *customData, Errors error);
       void (*LinkDone)(CP2P *p2p, char *address, int port, Errors error);
       void (*Stopped)(CP2P *p2p, Errors error);
       void (*TextReceived)(CP2P *p2p, int chanid, char *text);
       void (*DataReceived)(CP2P *p2p, int chanid, char *data, int len);
       bool (*FileSend)(CP2P *p2p, int chanid, char *filename, int64 size);
       bool (*FileReceive)(CP2P *p2p, int chanid, char *filename, int64 size);
       void (*FileProgress)(CP2P *p2p, int chanid, int64 position, int64 size);
       void (*FileDone)(CP2P *p2p, int chanid, Errors error);
       bool (*ForwardOpen)(CP2P *p2p, int forwid, ForwardTypes forwardtype, char *localaddress, int localport, char *remoteaddress, int remoteport);
       void (*ForwardClose)(CP2P *p2p, int forwid, Errors error);
       bool (*UserConnected)(CP2P *p2p, int forwid, int chanid, CP2PForwardUser *user);
       void (*UserDisconnected)(CP2P *p2p, int forwid, int chanid, CP2PForwardUser *user, Errors error);
       void (*Ping)(CP2P *p2p);
   } P2PEventsStruct;
 


Code sample

  • C++

Platforms

Windows
Mac OSX
Linux
BSD