
UserConnected event
Fires when user connects to forwarding channel.
Type
Boolean.Syntax
- C#
- C++
- VB.NET
delegate bool devP2P.UserConnectedEvent(IntPtr Handle, int forwardid, int chanid, IntPtr userhandle);
The UserConnected(Handle,forwid,chanid,user) syntax has these parts:
The UserConnected(Handle,forwid,chanid,user) syntax has these parts:
Handle | Reference to the devP2P instance. |
forwid | Index of the forwarded channel. |
chanid | Index of the channel that user will use. |
user | Reference to CP2PForwardUser with user details. |
Return value | Return true if you accept the user, or False to disconnect him. |
bool UserConnected(CP2P *p2p, int forwid, int chanid, CP2PForwardUser *user);
The UserConnected(p2p,forwid,chanid,user) syntax has these parts:
The UserConnected(p2p,forwid,chanid,user) syntax has these parts:
p2p | Pointer to devP2P instance that fired the event. |
forwid | Index of the forwarded channel. |
chanid | Index of the channel that user will use. |
user | Reference to CP2PForwardUser with user details. |
Return value | Return true if you accept the user, or False to disconnect him. |
Delegate Function P2P_UserConnectedEvent(ByVal Handle As IntPtr, ByVal forwardid As Integer, ByVal chanid As Integer, ByVal userhandle As IntPtr) As Boolean
The UserConnected(Handle,forwid,chanid,user) syntax has these parts:
The UserConnected(Handle,forwid,chanid,user) syntax has these parts:
Handle | Reference to the devP2P instance. |
forwid | Index of the forwarded channel. |
chanid | Index of the channel that user will use. |
user | Reference to CP2PForwardUser with user details. |
Return value | Return true if you accept the user, or False to disconnect him. |
Remarks
UserConnected event is fired after you have allowed user to connect and use forwarding they have chosen. From this point, user will be communicating with remote service through encrypted channel.There will be no further interference between devP2P and the user - all his data will be forwarded to remote devP2P peer, and vice versa. When user disconnects, UserDisconnected event will be fired.
To use this event, you should implement function by yourself in the code (based on function declaration), and set devP2P.Events.UserConnected structure member to point to your function.
Code sample
- C++
bool p2p_UserConnected(devP2Plib::CP2P *p2p, int forwid, int chanid, devP2Plib::CP2PForwardUser *user)
{
printf("%s] User connected\r\n", p2p->MyName);
return true;
}
int main(int argc, char **argv)
{
/* ... */
devP2Plib::CP2P *p1 = devP2Plib::CP2P::Create();
/* ... */
p1->Events.UserConnected = p2p_UserConnected;
/* ... */
}
{
printf("%s] User connected\r\n", p2p->MyName);
return true;
}
int main(int argc, char **argv)
{
/* ... */
devP2Plib::CP2P *p1 = devP2Plib::CP2P::Create();
/* ... */
p1->Events.UserConnected = p2p_UserConnected;
/* ... */
}
Platforms
WindowsMac OSX
Linux
BSD