//
//  RCWSOrder.m
//  Demo
//
//  Created by 余衡武 on 2024/10/5.
//

#import "RCWSOrder.h"
#import "RCTool.h"


@implementation RCWSOrder

#pragma mark - 批量指令URLs数组
+ (NSMutableArray *)getUrlsFrom:(NSArray *)hosts ips:(NSArray *)ips tokens:(NSArray *)tokens {
    NSMutableArray *urls = [NSMutableArray array];
    for (int i = 0; i < hosts.count; i++) {
        NSString *host = hosts[i];
        NSString *ip = ips[i];
        NSString *token = tokens[i];
        NSString *deviceID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
        NSString *url = [NSString stringWithFormat:@"%@/ws?ip=%@&Device-ID=%@&Authorization=%@", host, ip, deviceID,token];
        url = [NSString stringWithFormat:@"ws://%@", url];
        [urls addObject:url];
    }
    return urls;
}

+ (NSString *)getUrlFrom:(NSString *)host ip:(NSString *)ip token:(NSString *)token {
    NSString *deviceID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    NSString *url = [NSString stringWithFormat:@"%@/ws?ip=%@&Device-ID=%@&Authorization=%@", host, ip, deviceID,token];
    url = [NSString stringWithFormat:@"ws://%@", url];
    return url;
}

+ (NSString *)getPreUrlFrom:(NSString *)host ip:(NSString *)ip {
    NSString *url = [NSString stringWithFormat:@"%@/ws?ip=%@", host, ip];
    url = [NSString stringWithFormat:@"ws://%@", url];
    return url;
}

#pragma mark - 心跳包指令
+ (NSString *)heartBeatOrder {
    NSString *request_id = [RCTool timeStamp];
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"heartbeat"};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

#pragma mark - 批量操作指令
/**
 请求参数说明
 - 横屏
 - width: 1920，height: 1080
 - 竖屏
 - width: 1080，height: 1920
 - 还原分辨率：设置为0
 - width: 0，height: 0
 */
/// 1、同步操作-设置分辨率指令
+ (NSString *)resolutionOrder:(NSString *)width height:(NSString *)height {
    NSDictionary *content = @{@"width": @([width intValue]),
                              @"height": @([height intValue])};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_resolution",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 2、同步操作-设置DPI指令
+ (NSString *)dpiOrder:(NSString *)dpi {
    NSDictionary *content = @{@"dpi": @([dpi intValue])};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_dpi",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 3、全局root控制指令 root：0禁用, 1启用
+ (NSString *)rootSystemOrder:(int)root {
    NSDictionary *content = @{@"root": @(root)};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_root",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/*剪切板复制最大只支持5000个字节，剪切板超过5000个字节长度时只截取前5000字节**/
/// 4、剪贴板指令
+ (NSString *)clipboardOrder:(NSString *)text {
    if (text.length > 5000) { text = [text substringToIndex:5000]; }
    NSDictionary *content = @{@"data": text};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_clipboard",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 5、虚拟定位指令
+ (NSString *)virtualLocationOrder:(NSString *)longitude latitude:(NSString *)latitude {
    NSDictionary *content = @{@"longitude": longitude,
                              @"latitude": latitude};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"virtual_location",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 6、真机键盘开关指令 (mode: 1-开启 2-关闭) （WS 通道）
+ (NSString *)setKeyoardModeOrder:(int)mode {
    NSDictionary *content = @{@"type": @(mode)};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_input_method",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 7、真机键盘输入指令 (position: -1-删除 0-输入)（WS 通道）
+ (NSString *)setKeyoardInfoOrder:(NSString *)data position:(int)position {
    NSDictionary *content = @{@"data": data,
                              @"position": @(position)};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_input_transmission",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

#pragma mark - 应用管理指令
/// 1、启动指定的应用指令
+ (NSString *)startApp:(NSString *)packageName {
    NSDictionary *content = @{@"package_name": packageName};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"app_start",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 2、停止指定的应用指令
+ (NSString *)stopApp:(NSString *)packageName {
    NSDictionary *content = @{@"package_name": packageName};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"app_stop",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 3、卸载指定的应用指令
+ (NSString *)uninstallApp:(NSString *)packageName {
    NSDictionary *content = @{@"package_name": packageName};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"app_uninstall",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 4、隐藏预置的应用指令
+ (NSString *)hideApps:(NSArray *)packageNames {
    NSDictionary *content = @{@"package_list": packageNames};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"app_hide",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 5、显示预置的应用指令
+ (NSString *)showApps:(NSArray *)packageNames {
    NSDictionary *content = @{@"package_list": packageNames};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"app_display",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 6、应用root权限控制指令 root：0禁用, 1启用
+ (NSString *)rootApps:(NSArray *)packageNames root:(int)root {
    NSDictionary *content = @{@"package_list": packageNames,
                              @"root": @(root)};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"app_root",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 7、启用指定的应用指令
+ (NSString *)enableApp:(NSString *)packageName {
    NSDictionary *content = @{@"package_name": packageName};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"app_enable",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 8、停用指定的应用指令
+ (NSString *)disableApp:(NSString *)packageName {
    NSDictionary *content = @{@"package_name": packageName};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"app_disable",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 9、清理指定的应用指令
+ (NSString *)clearApp:(NSString *)packageName {
    NSDictionary *content = @{@"package_name": packageName};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"app_data_clean",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 10、设备新机（ brand-品牌 model-型号）
+ (NSString *)renewBrand:(NSString *)brand model:(NSString *)model {
    NSDictionary *device = @{@"brand": brand,
                            @"model": model};
    NSDictionary *content = @{@"device": device};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_new_device",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 11、开启推流应用预览
+ (NSString *)previewApp:(NSArray *)packageNames opt:(int)opt {
    NSDictionary *content = @{@"package_name": packageNames,
                              @"opt": @(opt)};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"app_preview",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 12、查询隐藏应用列表
+ (NSString *)queryAppHideList {
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"app_get_hide_list"};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 13、查询隐藏应用列表
+ (NSString *)queryAppAllList {
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"app_get_all_list"};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

#pragma mark - 预览图指令
/// 1、开启预览图推流指令
+ (NSString *)startPreview:(NSString *)width height:(NSString *)height interval:(NSString *)interval quality:(NSString *)quality {
    NSDictionary *content = @{@"width": width,
                              @"height": height,
                              @"interval": interval,
                              @"quality": quality};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_preview_start",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 2、停止预览图推流指令
+ (NSString *)stopPreview {
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_preview_stop"};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 3、设置预览图推流-图片宽高质量
//- (void)setPreview:(NSString *)width height:(NSString *)height interval:(NSString *)interval quality:(NSString *)quality {
//    NSDictionary *content = @{@"package_name": packageName};
//    NSString *request_id = [self timeStamp];
//
//    NSDictionary *dict = @{@"request_id": request_id,
//                           @"type": @"app_uninstall",
//                           @"content": content};
//    NSData *data = [dict mj_JSONData];
//    [self sendData:data];
//}
//
/// 4、设置预览图推流-设置时间间隔
//- (void)setPreview:(NSString *)interval {
//    NSDictionary *content = @{@"package_name": packageName};
//    NSString *request_id = [self timeStamp];
//
//    NSDictionary *dict = @{@"request_id": request_id,
//                           @"type": @"app_uninstall",
//                           @"content": content};
//    NSData *data = [dict mj_JSONData];
//    [self sendData:data];
//}

#pragma mark - 音视频Websocket指令
/// 订阅主题：屏幕亮度
+ (NSString *)subscribeBrightness {
    NSDictionary *content = @{@"topic": @"screen_brightness"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"subscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 取消订阅主题：屏幕亮度
+ (NSString *)unsubscribeBrightness {
    NSDictionary *content = @{@"topic": @"screen_brightness"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"unsubscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 订阅主题：剪贴板透传
+ (NSString *)subscribeClipboard {
    NSDictionary *content = @{@"topic": @"clipboard_transmission"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"subscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 取消订阅主题：剪贴板透传
+ (NSString *)unsubscribeClipboard {
    NSDictionary *content = @{@"topic": @"clipboard_transmission"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"unsubscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 订阅主题：屏幕方向
+ (NSString *)subscribeScreenOrientation {
    NSDictionary *content = @{@"topic": @"screen_orientation"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"subscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 取消订阅主题：屏幕方向
+ (NSString *)unsubscribeScreenOrientation {
    NSDictionary *content = @{@"topic": @"screen_orientation"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"unsubscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 订阅主题：分辨率变化
+ (NSString *)subscribeResolution {
    NSDictionary *content = @{@"topic": @"sys_resolution"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"subscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 取消订阅主题：分辨率变化
+ (NSString *)unsubscribeResolution {
    NSDictionary *content = @{@"topic": @"sys_resolution"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"unsubscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 订阅主题：创建快捷方式
+ (NSString *)subscribeAppShortcut {
    NSDictionary *content = @{@"topic": @"app_shortcut"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"subscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 取消订阅主题：创建快捷方式
+ (NSString *)unsubscribeAppShortcut {
    NSDictionary *content = @{@"topic": @"app_shortcut"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"unsubscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 订阅主题：应用启动
+ (NSString *)subscribeAppStart {
    NSDictionary *content = @{@"topic": @"app_start"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"subscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 取消订阅主题：应用启动
+ (NSString *)unsubscribeAppStart {
    NSDictionary *content = @{@"topic": @"app_start"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"unsubscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 订阅主题：GPS 变化
+ (NSString *)subscribeGPSVariation {
    NSDictionary *content = @{@"topic": @"gps_variation"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"subscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 取消订阅主题：GPS 变化
+ (NSString *)unsubscribeGPSVariation {
    NSDictionary *content = @{@"topic": @"gps_variation"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"unsubscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 订阅主题：音量变化
+ (NSString *)subscribeVolume {
    NSDictionary *content = @{@"topic": @"stream_volume"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"subscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 取消订阅主题：音量变化
+ (NSString *)unsubscribeVolume {
    NSDictionary *content = @{@"topic": @"stream_volume"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"unsubscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 音量设置
+ (NSString *)setVolumeWithStreamType:(uint)streamType percentage:(uint)percentage {
    NSDictionary *content = @{@"stream_type": @(streamType),
                              @"percentage": @(percentage)};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_set_stream_volume",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 订阅主题：消息透传
+ (NSString *)subscribeAppMessage {
    NSDictionary *content = @{@"topic": @"message_transmission"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"subscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 取消订阅主题：消息透传
+ (NSString *)unsubscribeAppMessage {
    NSDictionary *content = @{@"topic": @"message_transmission"};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"unsubscribe_topic",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 消息透传 - 发送消息
+ (NSString *)appMsgTransmission:(NSString *)packageName message:(NSString *)message {
    NSDictionary *content = @{@"package_name": packageName,
                              @"message": message};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"app_message_transmission",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 截图（quality ： 1～100 ）
+ (NSString *)screenShot:(int)quality {
    NSDictionary *content = @{@"quality": @(quality)};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_screenshot",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 查询推流画质
+ (NSString *)queryStreamQuality {
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_get_stream_quality_config"};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 查询分辨率
+ (NSString *)querySysResolution {
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_get_resolution"};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 查询横竖屏状态
+ (NSString *)queryScreenOriention {
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_get_screen_orientation"};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 吹一吹 取值范围 5-10秒
+ (NSString *)blowMargin:(int)time {
    NSDictionary *content = @{@"data": @(time)};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_blow",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 摇一摇 取值范围 3-10秒
+ (NSString *)shakeMargin:(int)time {
    NSDictionary *content = @{@"data": @(time)};
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_shake",
                           @"content": content};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 隐藏导航栏
+ (NSString *)hideNavBar {
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_hide_bar"};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 显示导航栏
+ (NSString *)showNavBar {
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_display_bar"};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 查询导航栏状态
+ (NSString *)queryNavBar {
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_get_bar_status"};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 查询全局 root 状态
+ (NSString *)queryRootStatus {
    NSString *request_id = [RCTool timeStamp];
    
    NSDictionary *dict = @{@"request_id": request_id,
                           @"type": @"sys_get_root"};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}


#pragma mark - 键盘透传指令
/// 1、设置真机输入法  2、设置云手机输入法（音视频通道）
+ (NSString *)setInputMethod:(int)mode {
    NSDictionary *data = @{@"type": @(mode)};
    
    NSDictionary *dict = @{@"data": data,
                           @"type": @"InputMethod"};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}

/// 2、设置真机输入内容（音视频通道）
/// content--输入的字符，可为空""
/// position--输入的位置 传入-1 并且KeyBoardData 为空时 会删除光标前的字符，位置>-1的时候为正常输入模式
+ (NSString *)setKeyoardInfo:(NSString *)content position:(int)position {
    NSDictionary *data = @{@"KeyBoardData": content,
                           @"position": @(position)};
    
    NSDictionary *dict = @{@"data": data,
                           @"type": @"KeyoardInfo"};
    NSString *json = [RCTool getJSONStringFrom:dict];
    return json;
}


#pragma mark - 辅助方法
+ (NSString *)getTypeFromOrder:(NSString *)order {
    NSDictionary *dict = [RCTool getDictFromJSONString:order];
    if ([[dict allKeys] containsObject:@"type"]) {
        return [NSString stringWithFormat:@"%@", [dict objectForKey:@"type"]];
    } else {
        return @"";
    }
}

@end
