The Event Handlers

That's all fine and good, but where did you connect? Fact is, currently, you haven't. The FindHosts method searches the hostname you've specified for valid sessions of this game. If it finds any, the FindHostResponse event is fired (which is why you hooked that method earlier). See Listing 16.6 for the implementation of this method, which is where the connection will occur.

Listing 16.6. Connecting to a Found Session
 /// <summary> /// Fired when a host has been found /// </summary> private void OnFoundHost(object sender, FindHostResponseEventArgs e) { // If you've already connected, don't try again if (isConnected) { return; } // Try to connect now isConnected = true; Peer connection = sender as Peer; connection.Connect(e.Message.ApplicationDescription, ...

Get Beginning 3D Game Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.