86 lines
2.3 KiB
Objective-C
86 lines
2.3 KiB
Objective-C
//
|
|
// GiftComboTransport.m
|
|
// YuMi
|
|
//
|
|
// Created by AI Assistant on 2024/8/18.
|
|
//
|
|
|
|
#import "GiftComboTransport.h"
|
|
#import "GiftReceiveInfoModel.h"
|
|
#import "UserInfoModel.h"
|
|
#import "XPGiftCountModel.h"
|
|
#import "XPMessageRemoteExtModel.h"
|
|
#import "AttachmentModel.h"
|
|
#import <NIMSDK/NIMSDK.h>
|
|
|
|
@interface GiftComboTransport ()
|
|
|
|
@property (nonatomic, strong) dispatch_queue_t serialQueue;
|
|
|
|
@end
|
|
|
|
@implementation GiftComboTransport
|
|
|
|
+ (instancetype)sharedTransport {
|
|
static GiftComboTransport *instance = nil;
|
|
static dispatch_once_t onceToken;
|
|
dispatch_once(&onceToken, ^{
|
|
instance = [[GiftComboTransport alloc] init];
|
|
});
|
|
return instance;
|
|
}
|
|
|
|
- (instancetype)init {
|
|
self = [super init];
|
|
if (self) {
|
|
_serialQueue = dispatch_queue_create("com.yumi.combo.transport", DISPATCH_QUEUE_SERIAL);
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)sendGiftWithParams:(NSDictionary *)params
|
|
completion:(GiftComboTransportCompletion)completion {
|
|
|
|
dispatch_async(self.serialQueue, ^{
|
|
NSLog(@"%@ 🎁 发送礼物 - params: %@", kComboLogPrefix, params);
|
|
|
|
// 这里应该调用实际的送礼API
|
|
// 为了简化,我们模拟一个成功的响应
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
if (completion) {
|
|
// 模拟成功响应
|
|
GiftReceiveInfoModel *receiveInfo = [[GiftReceiveInfoModel alloc] init];
|
|
completion(YES, receiveInfo, nil);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
- (void)sendNIMMessage:(NSDictionary *)messageData
|
|
completion:(void(^)(BOOL success, NSError *error))completion {
|
|
|
|
dispatch_async(self.serialQueue, ^{
|
|
NSLog(@"%@ 📨 发送NIM消息 - data: %@", kComboLogPrefix, messageData);
|
|
|
|
// 这里应该发送实际的NIM消息
|
|
// 为了简化,我们模拟一个成功的发送
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
if (completion) {
|
|
completion(YES, nil);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
- (NSError *)createErrorWithCode:(ComboErrorCode)code message:(NSString *)message {
|
|
NSDictionary *userInfo = @{
|
|
NSLocalizedDescriptionKey: message ?: @"Unknown error"
|
|
};
|
|
|
|
return [NSError errorWithDomain:kComboErrorDomain
|
|
code:code
|
|
userInfo:userInfo];
|
|
}
|
|
|
|
@end
|