Performing Actions in Our Session

We've made our connect call, but much like after our find hosts call, we don't really know what the outcome of that call was. Naturally, there is an event to handle this as well. Add the following handler to our InitializeDirectPlay method:

connection.ConnectComplete += new
    ConnectCompleteEventHandler(OnConnectComplete);

We also need the event handler method implementation, so add this as well:

 private void OnConnectComplete(object sender, ConnectCompleteEventArgs e) { // Check to see if we connected properly if (e.Message.ResultCode == ResultCode.Success) { this.BeginInvoke(new AddTextCallback(AddText), new object[] { "Connect Success." }); connected = true; this.BeginInvoke(new EnableCallback(EnableSendDataButton), ...

Get Managed DirectX® 9 Kick Start: Graphics and 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.