зеркало из https://github.com/nextcloud/talk-ios.git
Add raise hand signaling messages
Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
This commit is contained in:
Родитель
e347488543
Коммит
df46f40719
|
@ -29,7 +29,7 @@ extern NSString *const kRoomTypeVideo;
|
|||
extern NSString *const kRoomTypeScreen;
|
||||
|
||||
typedef enum {
|
||||
kNCSignalingMessageTypeUknown,
|
||||
kNCSignalingMessageTypeUnknown,
|
||||
kNCSignalingMessageTypeCandidate,
|
||||
kNCSignalingMessageTypeOffer,
|
||||
kNCSignalingMessageTypeAnswer,
|
||||
|
@ -37,7 +37,8 @@ typedef enum {
|
|||
kNCSignalingMessageTypeControl,
|
||||
kNCSignalingMessageTypeMute,
|
||||
kNCSignalingMessageTypeUnmute,
|
||||
kNCSignalingMessageTypeNickChanged
|
||||
kNCSignalingMessageTypeNickChanged,
|
||||
kNCSignalingMessageTypeRaiseHand
|
||||
} NCSignalingMessageType;
|
||||
|
||||
|
||||
|
@ -119,3 +120,13 @@ typedef enum {
|
|||
|
||||
@end
|
||||
|
||||
@interface NCRaiseHandMessage : NCSignalingMessage
|
||||
|
||||
- (instancetype)initWithFrom:(NSString *)from
|
||||
sendTo:(NSString *)to
|
||||
withPayload:(NSDictionary *)payload
|
||||
forRoomType:(NSString *)roomType;
|
||||
|
||||
- (instancetype)initWithValues:(NSDictionary *)values;
|
||||
|
||||
@end
|
||||
|
|
|
@ -59,6 +59,7 @@ static NSString * const kNCSignalingMessageTypeForceMuteKey = @"forceMute";
|
|||
static NSString * const kNCSignalingMessageTypeMuteKey = @"mute";
|
||||
static NSString * const kNCSignalingMessageTypeUnmuteKey = @"unmute";
|
||||
static NSString * const kNCSignalingMessageTypeNickChangedKey = @"nickChanged";
|
||||
static NSString * const kNCSignalingMessageTypeRaiseHandKey = @"raiseHand";
|
||||
|
||||
static NSString * const kNCSignalingMessageSdpKey = @"sdp";
|
||||
|
||||
|
@ -125,6 +126,8 @@ NSString *const kRoomTypeScreen = @"screen";
|
|||
message = [[NCUnmuteMessage alloc] initWithValues:jsonDict];
|
||||
} else if ([typeString isEqualToString:kNCSignalingMessageTypeNickChangedKey]) {
|
||||
message = [[NCNickChangedMessage alloc] initWithValues:jsonDict];
|
||||
} else if ([typeString isEqualToString:kNCSignalingMessageTypeRaiseHandKey]) {
|
||||
message = [[NCRaiseHandMessage alloc] initWithValues:jsonDict];
|
||||
} else {
|
||||
NSLog(@"Unexpected type: %@", typeString);
|
||||
}
|
||||
|
@ -144,6 +147,8 @@ NSString *const kRoomTypeScreen = @"screen";
|
|||
return [[NCUnmuteMessage alloc] initWithValues:jsonDict];
|
||||
} else if ([dataType isEqualToString:kNCSignalingMessageTypeNickChangedKey]) {
|
||||
return [[NCNickChangedMessage alloc] initWithValues:jsonDict];
|
||||
} else if ([dataType isEqualToString:kNCSignalingMessageTypeRaiseHandKey]) {
|
||||
return [[NCRaiseHandMessage alloc] initWithValues:jsonDict];
|
||||
}
|
||||
|
||||
NSString *dataAction = [data objectForKey:kNCSignalingMessageActionKey];
|
||||
|
@ -180,7 +185,7 @@ NSString *const kRoomTypeScreen = @"screen";
|
|||
}
|
||||
|
||||
- (NCSignalingMessageType)messageType {
|
||||
return kNCSignalingMessageTypeUknown;
|
||||
return kNCSignalingMessageTypeUnknown;
|
||||
}
|
||||
|
||||
+ (NSString *)getMessageSid {
|
||||
|
@ -552,3 +557,88 @@ NSString *const kRoomTypeScreen = @"screen";
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NCRaiseHandMessage
|
||||
|
||||
- (instancetype)initWithFrom:(NSString *)from sendTo:(NSString *)to withPayload:(NSDictionary *)payload forRoomType:(NSString *)roomType {
|
||||
|
||||
return [super initWithFrom:from
|
||||
to:to
|
||||
sid:[NCSignalingMessage getMessageSid]
|
||||
type:kNCSignalingMessageTypeRaiseHandKey
|
||||
payload:payload
|
||||
roomType:roomType];
|
||||
}
|
||||
|
||||
- (instancetype)initWithValues:(NSDictionary *)values {
|
||||
NSDictionary *dataDict = [[NSDictionary alloc] initWithDictionary:values];
|
||||
NSDictionary *payload = [dataDict objectForKey:kNCSignalingMessagePayloadKey];
|
||||
NSString *from = [values objectForKey:kNCSignalingMessageFromKey];
|
||||
// Get 'from' value from 'sender' using External Signaling
|
||||
NSDictionary *sender = [values objectForKey:kNCExternalSignalingMessageSenderKey];
|
||||
if (sender) {
|
||||
from = [sender objectForKey:kNCExternalSignalingMessageSessionIdKey];
|
||||
dataDict = [values objectForKey:kNCExternalSignalingMessageDataKey];
|
||||
payload = [dataDict objectForKey:kNCSignalingMessagePayloadKey];
|
||||
}
|
||||
return [super initWithFrom:from
|
||||
to:[dataDict objectForKey:kNCSignalingMessageToKey]
|
||||
sid:[dataDict objectForKey:kNCSignalingMessageSidKey]
|
||||
type:kNCSignalingMessageTypeRaiseHandKey
|
||||
payload:payload
|
||||
roomType:[dataDict objectForKey:kNCSignalingMessageRoomTypeKey]];
|
||||
}
|
||||
|
||||
- (NSData *)JSONData {
|
||||
NSError *error = nil;
|
||||
NSData *data =
|
||||
[NSJSONSerialization dataWithJSONObject:[self messageDict]
|
||||
options:0
|
||||
error:&error];
|
||||
if (error) {
|
||||
RTCLogError(@"Error serializing JSON: %@", error);
|
||||
return nil;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
- (NSString *)functionJSONSerialization
|
||||
{
|
||||
NSError *error;
|
||||
NSString *jsonString = nil;
|
||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:[self functionDict]
|
||||
options:0
|
||||
error:&error];
|
||||
|
||||
if (! jsonData) {
|
||||
NSLog(@"Error serializing JSON: %@", error);
|
||||
} else {
|
||||
jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
return jsonString;
|
||||
}
|
||||
|
||||
- (NSDictionary *)messageDict {
|
||||
return @{
|
||||
kNCSignalingMessageEventKey: kNCSignalingMessageKey,
|
||||
kNCSignalingMessageFunctionKey: [self functionJSONSerialization],
|
||||
kNCSignalingMessageSessionIdKey: self.from
|
||||
};
|
||||
}
|
||||
|
||||
- (NSDictionary *)functionDict {
|
||||
return @{
|
||||
kNCSignalingMessageToKey: self.to,
|
||||
kNCSignalingMessageRoomTypeKey: self.roomType,
|
||||
kNCSignalingMessageTypeKey: self.type,
|
||||
kNCSignalingMessagePayloadKey: self.payload,
|
||||
};
|
||||
}
|
||||
|
||||
- (NCSignalingMessageType)messageType {
|
||||
return kNCSignalingMessageTypeRaiseHand;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Загрузка…
Ссылка в новой задаче