Back to product page

SearchDone event


Fires when Search method completes its search for remote devP2P peer.

Syntax

  • C#
  • C++
  • VB.NET
delegate void devP2P.SearchDoneEvent(IntPtr Handle, string peerName, string peerXML, string customData, int errorno);
The SearchDone(Handle,peerName,peerXML,customData,error) syntax has these parts:
HandleReference to the devP2P instance.
peerNameName of the peer you are connected to.
peerXMLXML containing list of IP address where remote listens.
customDataCustom data provided by remote in Search method.
errorErrors value, ErrorNone if operation is successful, or other value defining the error that occurred.

void SearchDone(CP2P *p2p, char *peerName, char *peerXML, char *customData, Errors error);
The SearchDone(p2p,peerName,peerXML,customData,error) syntax has these parts:
p2pPointer to devP2P instance that fired the event.
peerNameName of the peer you are connected to.
peerXMLXML containing list of IP address where remote listens.
customDataCustom data provided by remote in Search method.
errorErrors value, ErrorNone if operation is successful, or other value defining the error that occurred.

Delegate Sub P2P_SearchDoneEvent(ByVal Handle As IntPtr, ByVal peerName, As String, ByVal peerXML As String, ByVal customData As String, ByVal errorno As Integer)
The SearchDone(Handle,peerName,peerXML,customData,error) syntax has these parts:
HandleReference to the devP2P instance.
peerNameName of the peer you are connected to.
peerXMLXML containing list of IP address where remote listens.
customDataCustom data provided by remote in Search method.
errorErrors value, ErrorNone if operation is successful, or other value defining the error that occurred.

Remarks

SearchDone event is fired after Search method was called, and devP2P finishes it search for remote peer. At this time this can be successful search (ErrorCode set to ErrorNone), or some error may have been occurred.

Even search was successful, it doesn't mean you're already linked to other devP2P. At this point you have enough information to attempt to connect using Link method - and you should do so within next few seconds otherwise IP/Port may become invalid (since your router can release his NAT translation table). It is possible that peerName argument is different than PeerName property, in case you used wildcards in PeerName property.

Typically, you will have basic code inside this event, such as
 
devP2P->Link(peeraddress);
 

but you MUST have code similar to above in your SearchDone method. Default implementation of SearchDone does call Link method, but if you change it you should manually call Link.

You can also inspect value of peeraddress argument, and add or remove elements from it.

To use this event, you should implement function by yourself in the code (based on function declaration), and set devP2P.Events.SearchDone structure member to point to your function.

Code sample

  • C++

Platforms

Windows
Mac OSX
Linux
BSD