
FileReceive event
Fires when remote devP2P wants to send us a file.
Type
Boolean.Syntax
- C#
- C++
- VB.NET
delegate bool devP2P.FileReceiveEvent(IntPtr Handle, int chanid, string filename, Int64 size);
The FileReceive(Handle,chanid,filename,size) syntax has these parts:
The FileReceive(Handle,chanid,filename,size) syntax has these parts:
Handle | Reference to the devP2P instance. |
chanid | Index of the channel where file is being transferred. |
filename | Path where file will be saved. |
size | Long integer, total size of the file that will be received. |
Return value | Return true if you accept file to be received. Return false to cancel the transfer. |
bool FileReceive(CP2P *p2p, int chanid, char *filename, int64 size);
The FileReceive(p2p,chanid,filename,size) syntax has these parts:
The FileReceive(p2p,chanid,filename,size) syntax has these parts:
p2p | Pointer to devP2P instance that fired the event. |
chanid | Index of the channel where file is being transferred. |
filename | Path where file will be saved. |
size | Long integer, total size of the file that will be received. |
Return value | Return true if you accept file to be received. Return false to cancel the transfer. |
Delegate Function P2P_FileReceiveEvent(ByVal Handle As IntPtr, ByVal chanid As Integer, ByVal filename As String, ByVal size As Int64) As Boolean
The FileReceive(Handle,chanid,filename,size) syntax has these parts:
The FileReceive(Handle,chanid,filename,size) syntax has these parts:
Handle | Reference to the devP2P instance. |
chanid | Index of the channel where file is being transferred. |
filename | Path where file will be saved. |
size | Long integer, total size of the file that will be received. |
Return value | Return true if you accept file to be received. Return false to cancel the transfer. |
Remarks
FileReceive event fires when remote devP2P peer wants to send us a file, and we have to decide if we will accept it or not. Event provides only filename (which you can change), and size of the file that is expected to arrive. If you return true, transfer will proceed. During the transfer, one or more FileProgress events will fire, and when transfer completes FileDone will fire.To use this event, you should implement function by yourself in the code (based on function declaration), and set devP2P.Events.FileReceive structure member to point to your function.
Code sample
- C++
bool p2p_FileReceive(devP2Plib::CP2P *p2p, int chanid, char *filename, int64 size)
{
printf("%s] Receiving file %s (%ld)\r\n", p2p->MyName, filename, (long)size);
return true;
}
int main(int argc, char **argv)
{
/* ... */
devP2Plib::CP2P *p1 = devP2Plib::CP2P::Create();
/* ... */
p1->Events.FileReceive = p2p_FileReceive;
/* ... */
}
{
printf("%s] Receiving file %s (%ld)\r\n", p2p->MyName, filename, (long)size);
return true;
}
int main(int argc, char **argv)
{
/* ... */
devP2Plib::CP2P *p1 = devP2Plib::CP2P::Create();
/* ... */
p1->Events.FileReceive = p2p_FileReceive;
/* ... */
}
Platforms
WindowsMac OSX
Linux
BSD