commit
19699c1fa2
|
@ -65,6 +65,22 @@ typedef enum RCTUDPError RCTUDPError;
|
|||
*/
|
||||
- (BOOL)bind:(u_int16_t) port address:(NSString*) address error:(NSError**)error;
|
||||
|
||||
/**
|
||||
* Join multicast groupt
|
||||
*
|
||||
* @param address
|
||||
* @return true if joined, false if there was an error
|
||||
*/
|
||||
- (BOOL)joinMulticastGroup:(NSString *)address error:(NSError **) error;
|
||||
|
||||
/**
|
||||
* leave multicast groupt
|
||||
*
|
||||
* @param address
|
||||
* @return true if joined, false if there was an error
|
||||
*/
|
||||
- (BOOL)leaveMulticastGroup:(NSString *)address error:(NSError **) error;
|
||||
|
||||
/**
|
||||
* send data to another host and port
|
||||
*
|
||||
|
|
|
@ -110,6 +110,24 @@ NSString *const RCTUDPErrorDomain = @"RCTUDPErrorDomain";
|
|||
return result && [_udpSocket beginReceiving:error];
|
||||
}
|
||||
|
||||
- (BOOL)joinMulticastGroup:(NSString *)address error:(NSError **) error
|
||||
{
|
||||
if(![_udpSocket joinMulticastGroup:address error:&error]){
|
||||
NSLog(@"Error joining multicast group: %@", error);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
- (BOOL)leaveMulticastGroup:(NSString *)address error:(NSError **) error
|
||||
{
|
||||
if(![_udpSocket leaveMulticastGroup:address error:&error]){
|
||||
NSLog(@"Error leaving multicast group: %@", error);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
- (void)udpSocket:(GCDAsyncUdpSocket *)sock didSendDataWithTag:(long)msgTag
|
||||
{
|
||||
NSNumber* tagNum = [NSNumber numberWithLong:msgTag];
|
||||
|
|
|
@ -106,12 +106,22 @@ RCT_EXPORT_METHOD(setBroadcast:(nonnull NSNumber*)cId
|
|||
|
||||
RCT_EXPORT_METHOD(addMembership:(nonnull NSNumber*)cId
|
||||
multicastAddress:(NSString *)address) {
|
||||
/* nop */
|
||||
UdpSocketClient *client = _clients[cId];
|
||||
|
||||
if (!client) return;
|
||||
|
||||
NSError *error = nil;
|
||||
[client joinMulticastGroup:address error:&error];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(dropMembership:(nonnull NSNumber*)cId
|
||||
multicastAddress:(NSString *)address) {
|
||||
/* nop */
|
||||
UdpSocketClient *client = _clients[cId];
|
||||
|
||||
if (!client) return;
|
||||
|
||||
NSError *error = nil;
|
||||
[client leaveMulticastGroup:address error:&error];
|
||||
}
|
||||
|
||||
- (void) onData:(UdpSocketClient*) client data:(NSData *)data host:(NSString *)host port:(uint16_t)port
|
||||
|
|
Loading…
Reference in New Issue