mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-13 22:29:45 +08:00
Replaced RCTSparseArray with NSDictionary
Reviewed By: jspahrsummers Differential Revision: D2651920 fb-gh-sync-id: 953e2ea33abfc7a3a553da95b13e9ab2bccc5a1c
This commit is contained in:
committed by
facebook-github-bot-4
parent
5a34a097f2
commit
fa0b45c58b
@@ -12,7 +12,6 @@
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTEventDispatcher.h"
|
||||
#import "RCTSRWebSocket.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTUtils.h"
|
||||
|
||||
@implementation RCTSRWebSocket (React)
|
||||
@@ -35,7 +34,7 @@
|
||||
|
||||
@implementation RCTWebSocketModule
|
||||
{
|
||||
RCTSparseArray *_sockets;
|
||||
NSMutableDictionary<NSNumber *, RCTSRWebSocket *> *_sockets;
|
||||
}
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
@@ -45,14 +44,14 @@ RCT_EXPORT_MODULE()
|
||||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_sockets = [RCTSparseArray new];
|
||||
_sockets = [NSMutableDictionary new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
for (RCTSRWebSocket *socket in _sockets.allObjects) {
|
||||
for (RCTSRWebSocket *socket in _sockets.allValues) {
|
||||
socket.delegate = nil;
|
||||
[socket close];
|
||||
}
|
||||
@@ -75,7 +74,7 @@ RCT_EXPORT_METHOD(send:(NSString *)message socketID:(nonnull NSNumber *)socketID
|
||||
RCT_EXPORT_METHOD(close:(nonnull NSNumber *)socketID)
|
||||
{
|
||||
[_sockets[socketID] close];
|
||||
_sockets[socketID] = nil;
|
||||
[_sockets removeObjectForKey:socketID];
|
||||
}
|
||||
|
||||
#pragma mark - RCTSRWebSocketDelegate methods
|
||||
|
||||
Reference in New Issue
Block a user