4

チャットモジュールで画像/ビデオを共有しようとしています。このためのサンプルコードを参照しましたが、ヘルプが見つかりませんでした。

Alos私はhttp://quickblox.com/modules/chat/を参照しましたが、フル機能のチャットモジュールを接続して、アプリにライブチャット機能を追加すると書かれています。高速でファイアウォールに対応し、堅牢で安全です。フル機能のチャットモジュールを購入する必要があるということですか?

正しい方法を教えてください。

ありがとう

4

4 に答える 4

5

はい、QuickBloxチャットでは、2人のユーザー間でファイル、ビデオ/オーディオを共有できます。

現在、iOS SDKは、ファイルの送信、ライブチャットのメソッドを提供していません。この機能は現在ベータテスト中です。エンドユーザー向けの簡単なインターフェースを開発しており、これにはもっと時間が必要です。12月末に終了することを願っています。

ただし、開発者がこの機能を自分で開発することは許可されています。これには何が必要ですか?

  1. 2人のユーザーの間に単純なTCP/UDPソケットを作成し、それを介してファイル、オーディオ/ビデオストリームを送信するだけです
  2. 1の場合、お互いのIPアドレスとポートを知る必要があります-自分のアドレス(IPとポート)を知ることができるSTUNプロトコルがあります-これがSTUNプロトコルの私のiOS実装ですhttps://github.com/soulfly/STUN-iOS
  3. 自分のアドレス(IPとポート)をすでに知っている場合は、単純なチャットメッセージを介して相手に送信するだけで、1つの項目を実行します。

必要なものはこれだけです

于 2012-12-02T13:04:45.237 に答える
2

UPD

QuickBloxは、開発者向けのVideoChatおよび無制限のAPI呼び出しをリリースしましたhttp://quickblox.com/blog/2013/02/quickblox-updates-videochat-and-unlimited-api-calls-for-developers

したがって、コードを試してアプリと統合する場合は、iOS用のシンプルコードサンプルhttp://quickblox.com/developers/SimpleSample-videochat-iosを確認してください。

于 2013-02-21T14:11:09.953 に答える
2

このようなuploadMethodがあります。

-(IBAction)uploadFile:(id)sender
{

    self.imagePicker = [[UIImagePickerController alloc] init];
    self.imagePicker.allowsEditing = NO;
    self.imagePicker.delegate = self;
    self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    [self presentViewController:self.imagePicker animated:YES completion:nil];
}

QBChatDelegateには、このメソッドがあります

- (void)completedWithResult:(Result*)result{
    // Upload file result
    if(result.success && [result isKindOfClass:[QBCFileUploadTaskResult class]])
    {

        QBCFileUploadTaskResult *res = (QBCFileUploadTaskResult *)result;
        NSUInteger uploadedFileID = res.uploadedBlob.ID;

        QBChatMessage *message = [[QBChatMessage alloc] init];
        message.recipientID = self.opponent.ID;

        NSMutableDictionary *msgDict = [[NSMutableDictionary alloc]init];
        [msgDict setValue:[NSNumber numberWithInt:uploadedFileID] forKey:@"fileID"];
        message.customParameters = msgDict;

        [[QBChat instance] sendMessage:message];

    }
    else
    {
        NSLog(@"errors=%@", result.errors);
    }
}

ここでは、アップロードされたファイルIDを取得し、これをメッセージとして送信しています。

chatDidReceiveNotificationで

- (void)chatDidReceiveMessageNotification:(NSNotification *)notification{
QBChatMessage *message = notification.userInfo[kMessage];

    if(message.customParameters != nil)
    {
        NSUInteger fileID = [message.customParameters[@"fileID"] integerValue];

        // download file by ID
        [QBContent TDownloadFileWithBlobID:fileID delegate:self];
    }
}

このメソッドは再びメソッドを呼び出しcompletedWithResult、そこにこのコードを追加します...

if(result.success && [result isKindOfClass:[QBCFileDownloadTaskResult class]]){
        QBCFileDownloadTaskResult *res = (QBCFileDownloadTaskResult *)result;

        if ([res file]) {

                UIImageView* imageView = [[UIImageView alloc] initWithImage:[UIImage imageWithData:[res file]]];
                [self.messages addObject:imageView];

            [self.messagesTableView reloadData];

        }

    }else{
        NSLog(@"errors=%@", result.errors);
    }

tableViewに画像を表示する場合は、cellForRowを次のように変更します。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    if([[self.messages objectAtIndex:indexPath.row]isKindOfClass:[QBChatMessage class]])
    {
        static NSString *ChatMessageCellIdentifier = @"ChatMessageCellIdentifier";

        ChatMessageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ChatMessageCellIdentifier];
        if(cell == nil){
            cell = [[ChatMessageTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ChatMessageCellIdentifier];
        }

        QBChatMessage *message = (QBChatMessage *)self.messages[indexPath.row];
        //
        [cell configureCellWithMessage:message is1To1Chat:self.opponent != nil];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;

    }
    else if ([[self.messages objectAtIndex:indexPath.row]isKindOfClass:[UIImageView class]])
    {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];

        if (nil == cell) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                          reuseIdentifier:@"CellIdentifier"];
        }
        UIImageView *receivedImage = [self.messages objectAtIndex:indexPath.row];
        [cell.contentView addSubview:receivedImage];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        return cell;

    }
}

私はこれを試しましたが、このコードは機能します。乾杯。

于 2014-02-21T12:32:14.157 に答える
0

要件が1-1チャットのみの場合は、このリンクを確認してください http://quickblox.com/developers/SimpleSample-chat_users-ios#Send_files これは1-1チャットで機能します。

しかし、部屋の場合、今のところ解決策を見つけることができません。私は理解しようとしています。誰かが方法を知っているなら、ここに投稿してください。

于 2013-11-30T08:46:27.720 に答える