Commit 9208178a authored by Chengzhao Li's avatar Chengzhao Li
Browse files

- change "CBCentralManagerScanOptionAllowDuplicatesKey" to NO

- remove used ncmcsession interface
parent 581970cc
......@@ -87,14 +87,16 @@ static MultiplayerController *_sharedMultiplayerController = nil;
-(void)startHost
{
if (self.isHost) {
[self.currentCentralService startBrowsingForPeers];
while (![self.currentCentralService startBrowsingForPeers]) {
}
}
}
-(void)startClient
{
if (!self.isHost) {
[self.currentPeripheralService startAdvertisingPeer];
while (![self.currentPeripheralService startAdvertisingPeer]) {
}
}
}
......
......@@ -259,7 +259,7 @@ static NCMCBluetoothLEManager *_sharedNCMCBluetoothLEManager = nil;
-(Boolean)startBrowsing
{
if (self.isDeviceReady) {
[self.centralManager scanForPeripheralsWithServices:@[[CBUUID UUIDWithString:self.session.serviceID]] options:@{CBCentralManagerScanOptionAllowDuplicatesKey: @YES}] ;
[self.centralManager scanForPeripheralsWithServices:@[[CBUUID UUIDWithString:self.session.serviceID]] options:@{CBCentralManagerScanOptionAllowDuplicatesKey: @NO}] ;
CCLOG(@"BluetoothLE central scanning started");
}
......
......@@ -20,7 +20,6 @@
-(void)notifyDidReceiveData:(NSData *)data fromPeer:(NCMCPeerID *)peerID;
-(void)onDataReceived:(NSData *)data from:(NSString *)identifier;
-(void)onPeerConnected:(NSString *)identifier;
-(void)onPeriphearalDisconnected:(NSString *)identifier; // used by central
-(void)onCentralDisconnected; // used by perihearal
......
......@@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithSession:(NCMCSession*)ncmcsession NS_DESIGNATED_INITIALIZER;
- (void)startBrowsingForPeers;
- (Boolean)startBrowsingForPeers;
- (void)stopBrowsingForPeers;
- (void)invitePeer:(NCMCPeerID *)peerID;
......
......@@ -26,11 +26,9 @@
return self;
}
-(void)startBrowsingForPeers
-(Boolean)startBrowsingForPeers
{
while (![[NCMCBluetoothLEManager instance]startBrowsing]) {
;
};
return [[NCMCBluetoothLEManager instance]startBrowsing];
}
-(void)stopBrowsingForPeers
......
......@@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithSession:(NCMCSession*)session NS_DESIGNATED_INITIALIZER;
- (void)startAdvertisingPeer;
- (Boolean)startAdvertisingPeer;
- (void)stopAdvertisingPeer;
@property (weak, NS_NONATOMIC_IOSONLY, nullable) id<NCMCPeripheralServiceDelegate> delegate;
......
......@@ -26,12 +26,9 @@
return self;
}
-(void)startAdvertisingPeer
-(Boolean)startAdvertisingPeer
{
while (![[NCMCBluetoothLEManager instance]startAdvertising]) {
;
}
;
return [[NCMCBluetoothLEManager instance]startAdvertising];
}
-(void)stopAdvertisingPeer
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment