-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBrooklynBridge.m
60 lines (47 loc) · 1.54 KB
/
BrooklynBridge.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// BrooklynBridge.m
// brooklyn
//
// Created by EthanRDoesMC on 12/27/20.
//
#import "BrooklynBridge.h"
@interface BrooklynBridge ()
@property (nonatomic, strong) AVAudioPlayer * loadingPlayer;
@end
@implementation BrooklynBridge
+ (instancetype)sharedBridge {
static BrooklynBridge *_sharedBridge = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedBridge = [BrooklynBridge new];
});
return _sharedBridge;
}
+ (BOOL)riseAndShineIMDaemon {
IMDaemonController* controller = [NSClassFromString(@"IMDaemonController") sharedController];
BOOL connectResult = [controller connectToDaemon];
NSLog(@"Attempted to connect to daemon with result: %hhd", connectResult);
return connectResult;
}
+(NSArray *)conversationArray {
[BrooklynBridge riseAndShineIMDaemon];
NSMutableArray *returnArray = [NSMutableArray new];
for (IMChat * c in [[IMChatRegistry sharedInstance] allExistingChats]) {
[returnArray addObject:[[CKConversation alloc] initWithChat:c]];
}
// NOT GOOD. CREATES A BUNCH'A OBJECTS.
return returnArray;
}
-(void)playLoadingChime {
if (!self.loadingPlayer) {
_loadingPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"loadingChime" ofType:@"aiff"]] error:nil];
_loadingPlayer.numberOfLoops = -1;
}
[_loadingPlayer play];
}
-(void)stopLoadingChime {
[_loadingPlayer stop];
[_loadingPlayer setCurrentTime:0];
}
#pragma mark - Message Sending
@end