Commit 661f4a3e authored by Chengzhao Li's avatar Chengzhao Li
Browse files

- add method getConnectedPeers

parent a7aec9cb
......@@ -5,8 +5,6 @@
// Created by Chengzhao Li on 2016-06-21.
// Copyright © 2016 Apportable. All rights reserved.
//
#import "NCMCPeerID.h"
#import "Core/NCMCPeerID+Core.h"
@implementation NCMCPeerID
......
......@@ -29,6 +29,8 @@ NS_ASSUME_NONNULL_BEGIN
-(void)sendData:(NSData *)data toPeers:(NSArray<NCMCPeerID *> *)peerIDs;
-(NSArray<NCMCPeerID*>*)getConnectedPeers;
@property (weak, NS_NONATOMIC_IOSONLY, nullable) id<NCMCSessionDelegate> delegate;
@end
......
......@@ -56,6 +56,19 @@ typedef enum NCMCSystemMessageType {
}
}
-(NSArray<NCMCPeerID*>*)getConnectedPeers
{
NSMutableArray* peers = [[NSMutableArray alloc]init];
NSEnumerator *enmuerator = [self.connectedDevices objectEnumerator];
for (NCMCDeviceInfo *info in enmuerator) {
NCMCPeerID *peerID= [[NCMCPeerID alloc]initWithDisplayName:info.name andIdentifier:info.identifier];
[peers addObject:peerID];
}
return peers;
}
-(void)notifyPeerStateChanged:(NCMCPeerID *)peerID newState:(NCMCSessionState)state
{
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(session:peer:didChangeState:)]) {
......
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