
DataReceived event
Fires when data is received from remote.
Syntax
- C#
- C++
- VB.NET
delegate void devP2P.DataReceivedEvent(IntPtr Handle, int chanid, String data, int len);
The DataReceived(Handle,chanid,data,len) syntax has these parts:
The DataReceived(Handle,chanid,data,len) syntax has these parts:
Handle | Reference to the devP2P instance. |
chanid | Index of the channel where data arrived. |
data | String with incoming data. |
len | Size of incoming data. |
void DataReceived(CP2P *p2p, int chanid, char *data, int len);
The DataReceived(p2p,chanid,data,len) syntax has these parts:
The DataReceived(p2p,chanid,data,len) syntax has these parts:
p2p | Pointer to devP2P instance that fired the event. |
chanid | Index of the channel where data arrived. |
data | Pointer to buffer in memory with the data. |
len | Size of the memory buffer. |
Delegate Sub P2P_DataReceivedEvent(ByVal Handle As IntPtr, ByVal chanid As Integer, ByVal data As String, ByVal len As Integer)
The DataReceived(Handle,chanid,data,len) syntax has these parts:
The DataReceived(Handle,chanid,data,len) syntax has these parts:
Handle | Reference to the devP2P instance. |
chanid | Index of the channel where data arrived. |
data | String with incoming data. |
len | Size of incoming data. |
Remarks
DataReceived event will fire as result of remote peer's SendData method call. When data arrives, devP2P will provide it through this event.If you prefer to send/receive text messages, use SendText method and TextReceived event instead.
To use this event, you should implement function by yourself in the code (based on function declaration), and set devP2P.Events.DataReceived structure member to point to your function.
Code sample
- C++
void p2p_DataReceived(devP2Plib::CP2P *p2p, int chanid, char *data, int len)
{
printf("%s] Received %d bytes of data\r\n", p2p->MyName, len);
}
int main(int argc, char **argv)
{
/* ... */
devP2Plib::CP2P *p1 = devP2Plib::CP2P::Create();
/* ... */
p1->Events.DataReceived = p2p_DataReceived;
/* ... */
}
{
printf("%s] Received %d bytes of data\r\n", p2p->MyName, len);
}
int main(int argc, char **argv)
{
/* ... */
devP2Plib::CP2P *p1 = devP2Plib::CP2P::Create();
/* ... */
p1->Events.DataReceived = p2p_DataReceived;
/* ... */
}
Platforms
WindowsMac OSX
Linux
BSD