
StateChange event
Fires when devP2P changes its state.
Syntax
- C#
- C++
- VB.NET
delegate void devP2P.StateChangeEvent(IntPtr Handle, int state);
The StateChange(Handle,state) syntax has these parts:
The StateChange(Handle,state) syntax has these parts:
Handle | Reference to the devP2P instance. |
state | States value. Current state. |
void StateChange(CP2P *p2p, States state);
The StateChange(p2p,state) syntax has these parts:
The StateChange(p2p,state) syntax has these parts:
p2p | Pointer to devP2P instance that fired the event. |
state | States value. Current state. |
Delegate Sub P2P_StateChangeEvent(ByVal Handle As IntPtr, ByVal state As Integer)
The StateChange(Handle,state) syntax has these parts:
The StateChange(Handle,state) syntax has these parts:
Handle | Reference to the devP2P instance. |
state | States value. Current state. |
Remarks
StateChange event is fired each time devP2P changes its internal state. Initially it is set to StateDisconnected, but as you call devP2P's methods it will be changed to StateListening, StateLinking etc..Using this event you can determine whether there is anything happening with devP2P. You can access current state using State property.
To use this event, you should implement function by yourself in the code (based on function declaration), and set devP2P.Events.StateChange structure member to point to your function.
Code sample
- C++
void p2p_StateChange(devP2Plib::CP2P *p2p, devP2Plib::States state)
{
printf("%s] State changed to %s\r\n", p2p->MyName, p2p->StateText(state));
}
int main(int argc, char **argv)
{
/* ... */
devP2Plib::CP2P *p1 = devP2Plib::CP2P::Create();
/* ... */
p1->Events.StateChange = p2p_StateChange;
/* ... */
}
{
printf("%s] State changed to %s\r\n", p2p->MyName, p2p->StateText(state));
}
int main(int argc, char **argv)
{
/* ... */
devP2Plib::CP2P *p1 = devP2Plib::CP2P::Create();
/* ... */
p1->Events.StateChange = p2p_StateChange;
/* ... */
}
Platforms
WindowsMac OSX
Linux
BSD