Skip to content

Commit a5aed2d

Browse files
Merge pull request #269 from TakayukiHoshi1984/modify_instance_management
インスタンス生成ロジックの見直し
2 parents cbac300 + 49fbf2b commit a5aed2d

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

dConnectDevicePlugin/dConnectDeviceHost/dConnectDeviceHost/Classes/DPHostDevicePlugin.m

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#import <DConnectSDK/DConnectFileManager.h>
1111
#import <DConnectSDK/DConnectEventManager.h>
12-
#import <DConnectSDK/DConnectMemoryCacheController.h>
1312
#import <DConnectSDK/DConnectServiceManager.h>
1413

1514
#import "DPHostDevicePlugin.h"
@@ -22,11 +21,6 @@
2221
@implementation DPHostDevicePlugin
2322

2423
+ (void) initialize {
25-
// イベントマネージャの準備
26-
Class clazz = [DPHostDevicePlugin class];
27-
DConnectEventManager *eventMgr =
28-
[DConnectEventManager sharedManagerForClass:clazz];
29-
[eventMgr setController:[DConnectMemoryCacheController new]];
3024
}
3125

3226
- (id) init {

dConnectSDK/dConnectSDKForIOS/DConnectSDK/Classes/DConnectDevicePlugin.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,15 @@ - (id) initWithObject: (id) object {
5050
self.pluginVersionName = @"1.0.0";
5151
self.pluginId = [md5Proc generateSignature: self.pluginName];
5252

53+
// DeviceConnectサービス管理クラスの初期化
5354
DConnectServiceManager *serviceManager = [DConnectServiceManager sharedForClass: [object class]];
5455
[serviceManager setPlugin: self];
5556
[self setServiceProvider: serviceManager];
5657

58+
// イベント管理クラスの初期化
59+
id<DConnectEventCacheController> ctrl = [self eventCacheController];
60+
[[DConnectEventManager sharedManagerForClass:[self class]] setController:ctrl];
61+
5762
// プロファイル追加
5863
[self addProfile:[[DConnectAuthorizationProfile alloc] initWithObject:self]];
5964
[self addProfile:[[DConnectServiceDiscoveryProfile alloc] initWithServiceProvider: self.serviceProvider]];
@@ -228,6 +233,11 @@ - (NSArray *) serviceProfilesWithServiceId: (NSString *) serviceId {
228233
return nil;
229234
}
230235

236+
- (id<DConnectEventCacheController>) eventCacheController
237+
{
238+
return [[DConnectMemoryCacheController alloc] init];
239+
}
240+
231241

232242
- (NSString*)iconFilePath:(BOOL)isOnline
233243
{

dConnectSDK/dConnectSDKForIOS/DConnectSDK/DConnectSDK/DConnectDevicePlugin.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#import <DConnectSDK/DConnectRequestMessage.h>
1717
#import <DConnectSDK/DConnectResponseMessage.h>
1818
#import <DConnectSDK/DConnectServiceProvider.h>
19+
#import <DConnectSDK/DConnectEventCacheController.h>
1920

2021

2122
/*!
@@ -115,6 +116,8 @@
115116
*/
116117
- (void)applicationWillEnterForeground;
117118

119+
- (id<DConnectEventCacheController>) eventCacheController;
120+
118121
- (NSArray *) serviceProfilesWithServiceId: (NSString *) serviceId;
119122

120123
- (NSString*)iconFilePath:(BOOL)isOnline;

0 commit comments

Comments
 (0)