update for react-native 11.0

json numbers are converted to NSNumber
NSNumber parameters must be marked nonnull (as of v0.10.0-rc)
This commit is contained in:
Andy Prock 2015-09-17 12:52:02 -07:00
parent c1d9f7ff40
commit 8f7bc1e702
1 changed files with 17 additions and 17 deletions

View File

@ -20,7 +20,7 @@ RCT_EXPORT_MODULE()
@synthesize bridge = _bridge; @synthesize bridge = _bridge;
RCT_EXPORT_METHOD(createSocket:(NSString*)cId withOptions:(NSDictionary*)options) RCT_EXPORT_METHOD(createSocket:(nonnull NSNumber*)cId withOptions:(NSDictionary*)options)
{ {
if (!_clients) _clients = [[NSMutableDictionary alloc] init]; if (!_clients) _clients = [[NSMutableDictionary alloc] init];
@ -39,7 +39,7 @@ RCT_EXPORT_METHOD(createSocket:(NSString*)cId withOptions:(NSDictionary*)options
[_clients setObject:client forKey:cId]; [_clients setObject:client forKey:cId];
} }
RCT_EXPORT_METHOD(bind:(NSString*)cId RCT_EXPORT_METHOD(bind:(nonnull NSNumber*)cId
port:(int)port port:(int)port
address:(NSString *)address address:(NSString *)address
callback:(RCTResponseSenderBlock)callback) callback:(RCTResponseSenderBlock)callback)
@ -57,10 +57,10 @@ RCT_EXPORT_METHOD(bind:(NSString*)cId
callback(@[[NSNull null], [client address]]); callback(@[[NSNull null], [client address]]);
} }
RCT_EXPORT_METHOD(send:(NSString*)cId RCT_EXPORT_METHOD(send:(nonnull NSNumber*)cId
string:(NSString*)base64String string:(nonnull NSNumber*)base64String
port:(int)port port:(int)port
address:(NSString*)address address:(nonnull NSNumber*)address
callback:(RCTResponseSenderBlock)callback) { callback:(RCTResponseSenderBlock)callback) {
UdpSocketClient* client = [self findClient:cId callback:callback]; UdpSocketClient* client = [self findClient:cId callback:callback];
if (!client) return; if (!client) return;
@ -71,7 +71,7 @@ RCT_EXPORT_METHOD(send:(NSString*)cId
[client send:data remotePort:port remoteAddress:address callback:callback]; [client send:data remotePort:port remoteAddress:address callback:callback];
} }
RCT_EXPORT_METHOD(close:(NSString*)cId RCT_EXPORT_METHOD(close:(nonnull NSNumber*)cId
callback:(RCTResponseSenderBlock)callback) { callback:(RCTResponseSenderBlock)callback) {
UdpSocketClient* client = [self findClient:cId callback:callback]; UdpSocketClient* client = [self findClient:cId callback:callback];
if (!client) return; if (!client) return;
@ -82,7 +82,7 @@ RCT_EXPORT_METHOD(close:(NSString*)cId
if (callback) callback(@[]); if (callback) callback(@[]);
} }
RCT_EXPORT_METHOD(setBroadcast:(NSString*)cId RCT_EXPORT_METHOD(setBroadcast:(nonnull NSNumber*)cId
flag:(BOOL)flag flag:(BOOL)flag
callback:(RCTResponseSenderBlock)callback) { callback:(RCTResponseSenderBlock)callback) {
UdpSocketClient* client = [self findClient:cId callback:callback]; UdpSocketClient* client = [self findClient:cId callback:callback];
@ -110,7 +110,7 @@ RCT_EXPORT_METHOD(setBroadcast:(NSString*)cId
]; ];
} }
-(UdpSocketClient*)findClient:(NSString*)cId callback:(RCTResponseSenderBlock)callback -(UdpSocketClient*)findClient:(nonnull NSNumber*)cId callback:(RCTResponseSenderBlock)callback
{ {
UdpSocketClient *client = [_clients objectForKey:cId]; UdpSocketClient *client = [_clients objectForKey:cId];
if (!client) { if (!client) {