Permalink
Browse files

Include ourselves when using the 0.0.0.0 broadcast

  • Loading branch information...
1 parent 322a37d commit 7a4ee578b1de022d69a24e712becdcd6341dbc00 Jonathan del Strother committed Sep 10, 2009
Showing with 11 additions and 3 deletions.
  1. +11 −3 BBOSCManager.m
View
@@ -12,22 +12,30 @@
@interface BBOSCBroadcastPort : NSObject {
OSCManager* oscManager;
- int port;
+ int portNumber;
+ OSCOutPort* localPort;
}
-(id)initWithManager:(OSCManager*)manager atPort:(int)p;
@end
@implementation BBOSCBroadcastPort
-(id)initWithManager:(OSCManager*)manager atPort:(int)p {
if (self = [super init]) {
oscManager = manager;
- port = p;
+ portNumber = p;
+ // Make sure that the OSC Manager knows we can broadcast to ourselves
+ localPort = [[oscManager createNewOutputToAddress:@"127.0.0.1" atPort:p] retain];
}
return self;
}
+-(void)dealloc {
+ [oscManager removeOutput:localPort];
+ [localPort release];
+ [super dealloc];
+}
-(void)sendThisMessage:(OSCMessage*)message {
// Broadcast to all discovered outPorts with the same port number as us.
[[oscManager outPortArray] rdlock];
- NSArray* suitablePorts = [[[oscManager outPortArray] array] select:^BOOL(OSCOutPort* oscPort){return (oscPort.port == port);}];
+ NSArray* suitablePorts = [[[oscManager outPortArray] array] select:^BOOL(OSCOutPort* oscPort){return (oscPort.port == portNumber);}];
[[oscManager outPortArray] unlock];
[suitablePorts makeObjectsPerformSelector:@selector(sendThisMessage:) withObject:message];

0 comments on commit 7a4ee57

Please sign in to comment.