Skip to content

Commit

Permalink
Create SinchModule
Browse files Browse the repository at this point in the history
  • Loading branch information
pepebecker committed Sep 9, 2019
1 parent f1950e7 commit 3bfb5ff
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChatSDKCore/Classes/Convenience/BModuleHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ -(void) activateModulesForXMPP {

-(void) activateCommonModules: (NSString *) server {
[self activateModuleForName:@"BBlockingModule"];
[self activateModuleForName:@"BSinchModule"];
[self activateModuleForName:@"BLastOnlineModule"];
[self activateModuleForName:@"BAudioMessageModule"];
[self activateModuleForName:@"BVideoMessageModule"];
Expand Down
3 changes: 3 additions & 0 deletions ChatSDKCore/Classes/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
#import <ChatSDK/PPublicThreadHandler.h>
#import <ChatSDK/PEncryptionHandler.h>
#import <ChatSDK/PBlockingHandler.h>
#import <ChatSDK/PCallHandler.h>
#import <ChatSDK/PCallDelegate.h>
#import <ChatSDK/PCall.h>
#import <ChatSDK/PLastOnlineHandler.h>
#import <ChatSDK/PNearbyUsersHandler.h>
#import <ChatSDK/PReadReceiptHandler.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
@property (nonatomic, readwrite) id<PSearchHandler> search;
@property (nonatomic, readwrite) id<PPublicThreadHandler> publicThread;
@property (nonatomic, readwrite) id<PBlockingHandler> blocking;
@property (nonatomic, readwrite) id<PCallHandler> calling;
@property (nonatomic, readwrite) id<PLastOnlineHandler> lastOnline;
@property (nonatomic, readwrite) id<PNearbyUsersHandler> nearbyUsers;
@property (nonatomic, readwrite) id<PReadReceiptHandler> readReceipt;
Expand Down
27 changes: 27 additions & 0 deletions ChatSDKCore/Classes/Interfaces/PCall.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// PCall.h
// ChatSDK
//
// Created by Pepe Becker on 9/3/19.
//

#ifndef PCall_h
#define PCall_h

@protocol PCall <NSObject>

- (void)answer;
- (void)hangup;
- (void)pauseVideo;
- (void)resumeVideo;

- (void)setDelegate:(id<PCallDelegate>)delegate;
- (id<PCallDelegate>)delegate;

- (NSString *)callId;
- (NSString *)remoteUserId;
- (BOOL)isOutgoing;

@end

#endif /* PCall_h */
22 changes: 22 additions & 0 deletions ChatSDKCore/Classes/Interfaces/PCallDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// PCallDelegate.h
// ChatSDK
//
// Created by Pepe Becker on 9/5/19.
//

#ifndef PCallDelegate_h
#define PCallDelegate_h

@protocol PCall;

@protocol PCallDelegate <NSObject>
@optional
- (void)callDidEnd:(id<PCall>)call;
- (void)callDidProgress:(id<PCall>)call;
- (void)callDidEstablish:(id<PCall>)call;
- (void)callDidPauseVideo:(id<PCall>)call;
- (void)callDidResumeVideo:(id<PCall>)call;
@end

#endif /* PCallDelegate_h */
43 changes: 43 additions & 0 deletions ChatSDKCore/Classes/Interfaces/PCallHandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// PCallHandler.h
// ChatSDKModules
//
// Created by Pepe Becker on 9/3/19.
//

#ifndef PCallHandler_h
#define PCallHandler_h

@class RXPromise;
@protocol PCall;

@protocol PCallHandler <NSObject>

- (RXPromise *)startWithUserId:(NSString *)userId;
- (RXPromise *)callUserWithId:(NSString *)userId;
- (id<PCall>)activeCall;
- (id<PCall>)incomingCall;
- (void)answerIncomingCall;
- (void)hangupIncomingCall;
- (void)hangupActiveCall;

- (UIView *)localView;
- (UIView *)remoteView;

- (void)enableSpeaker;
- (void)disableSpeaker;

- (int)captureDevicePosition;
- (void)setCaptureDevicePosition:(int)i;
- (void)toggleCaptureDevicePosition;

- (UINavigationController *)callNavigationController;
- (UINavigationController *)incomingCallNavigationController;
- (UIViewController *)callViewController;
- (UIViewController *)incomingCallViewController;
- (void)setCallViewControllerClass:(Class)controllerClass;
- (void)setIncomingCallViewControllerClass:(Class)controllerClass;

@end

#endif /* PCallHandler_h */
3 changes: 3 additions & 0 deletions ChatSDKCore/Classes/Interfaces/PNetworkAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
@protocol PPublicThreadHandler;
@protocol PLastOnlineHandler;
@protocol PBlockingHandler;
@protocol PCallHandler;
@protocol PNearbyUsersHandler;
@protocol PReadReceiptHandler;
@protocol PStickerMessageHandler;
Expand Down Expand Up @@ -98,6 +99,7 @@
-(id<PPublicThreadHandler>) publicThread;
-(id<PLastOnlineHandler>) lastOnline;
-(id<PBlockingHandler>) blocking;
-(id<PCallHandler>) calling;
-(id<PNearbyUsersHandler>) nearbyUsers;
-(id<PReadReceiptHandler>) readReceipt;
-(id<PStickerMessageHandler>) stickerMessage;
Expand Down Expand Up @@ -125,6 +127,7 @@
-(void) setPublicThread: (id<PPublicThreadHandler>) publicThread;
-(void) setLastOnline: (id<PLastOnlineHandler>) lastOnline;
-(void) setBlocking: (id<PBlockingHandler>) blocking;
-(void) setCalling: (id<PCallHandler>) calling;
-(void) setNearbyUsers: (id<PNearbyUsersHandler>) nearbyUsers;
-(void) setReadReceipt: (id<PReadReceiptHandler>) readReceipt;
-(void) setStickerMessage: (id<PStickerMessageHandler>) stickerMessage;
Expand Down
1 change: 1 addition & 0 deletions ChatSDKCore/Classes/Session/BChatSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
+(id<PSearchHandler>) search;
+(id<PPublicThreadHandler>) publicThread;
+(id<PBlockingHandler>) blocking;
+(id<PCallHandler>) calling;
+(id<PLastOnlineHandler>) lastOnline;
+(id<PNearbyUsersHandler>) nearbyUsers;
+(id<PReadReceiptHandler>) readReceipt;
Expand Down
4 changes: 4 additions & 0 deletions ChatSDKCore/Classes/Session/BChatSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ -(BBackgroundPushNotificationQueue *) pushQueue {
return self.a.blocking;
}

+(id<PCallHandler>) calling {
return self.a.calling;
}

+(id<PLastOnlineHandler>) lastOnline {
return self.a.lastOnline;
}
Expand Down
Binary file added ChatSDKUI/Assets/call_white_24pt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ChatSDKUI/Assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ChatSDKUI/Assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions ChatSDKUI/Classes/Components/Chat View/BChatViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,25 @@ -(void) viewDidLoad {
[self updateSubtitle];

[super setAudioEnabled: BChatSDK.audioMessage != Nil];

if (BChatSDK.calling) {
UIBarButtonItem * callItem = [[UIBarButtonItem alloc] initWithTitle:@"Call" style:UIBarButtonItemStylePlain target:self action:@selector(call)];
self.navigationItem.rightBarButtonItem = callItem;
}

// Add the initial batch of messages
NSArray<PMessage> * messages = [BChatSDK.db loadMessagesForThread:_thread newest:BChatSDK.config.messagesToLoadPerBatch];
messages = [messages sortedArrayUsingComparator:[BMessageSorter oldestFirst]];
[self setMessages:messages scrollToBottom:NO animate:NO force: YES];
}

-(void) call {
if (!BChatSDK.calling) return;
[BChatSDK.calling callUserWithId:_thread.otherUser.entityID];
UIViewController * controller = [BChatSDK.calling callNavigationController];
[self presentViewController:controller animated:YES completion:nil];
}

-(void) updateSubtitle {

if (BChatSDK.config.userChatInfoEnabled) {
Expand Down
1 change: 1 addition & 0 deletions Xcode/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ target 'ChatSDK Demo' do
# pod 'FBSDKLoginKit'


#pod "ChatSDKModules/SinchModule", :path => "../ChatSDKModules"
#pod "ChatSDKModules/StickerMessage", :path => "../ChatSDKModules"
#pod "ChatSDKModules/KeyboardOverlayOptions", :path => "../ChatSDKModules"
#pod "ChatSDKModules/ContactBook", :path => "../ChatSDKModules"
Expand Down

0 comments on commit 3bfb5ff

Please sign in to comment.