You get the Network session simply by accessing the default session and activating it. Like this:
MIDINetworkSession *session = [MIDINetworkSession defaultSession]; session.connectionPolicy = MIDINetworkConnectionPolicy_Anyone; session.enabled=YES;But now you still don't have any connections, so you will have to listen for them until your host has connected to your application. The best way to do this, is by using a thread:
[NSThread detachNewThreadSelector:@selector(waitForConnections:) toTarget:self withObject:session];Now you will have to create the
waitForConnections:
method:
- (void) waitForConnections:(id) argument { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; MIDINetworkSession *session = (MIDINetworkSession *)argument; BOOL found = NO; while (!found) { NSSet *connections =[session connections]; if ((cons = [connections count]) > 0) { found = YES; } else { [NSThread sleepForTimeInterval:1]; } } [... do something with connections ....] [pool release]; }To use Network MIDI on a PC, you will have to install rtpMIDI, works just like Network MIDI on the Mac. I will post more on handling the MIDI part when I get there later.