gpt4 book ai didi

ios - XMPPFramework-TURNSocket无法接收到我自己发送的数据吗?

转载 作者:行者123 更新时间:2023-12-01 17:10:20 26 4
gpt4 key购买 nike

我将openfire用作xmpp服务器,并希望通过Turnsocket传输文件。

openfire(本地)配置:

xmpp.auth.anonymous                true
xmpp.domain local
xmpp.enabled true
xmpp.externalip proxy.local, 192.168.1.101, 127.0.0.1
xmpp.proxy.enabled true
xmpp.proxy.port 7777
xmpp.proxy.transfer.required false
xmpp.server.socket.active true
xmpp.session.conflict.limit 0
xmpp.socket.ssl.active true

我在本地环境中测试了文件传输,一个用户由Simulator(发件人)登录,另一用户由Device(iPod,接收器)登录。
  • TURNSocket.m(均已更改),更改代理
    + (void)initialize {
    ...
    proxyCandidates = [[NSMutableArray alloc] initWithObjects:@"local", nil];
    ...
    }
  • 在发送方和接收方都配置
    - (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq {

    ...

    if ([TURNSocket isNewStartTURNRequest:iq]) {

    NSLog(@"IS NEW TURN request Receive.. TURNSocket..................");

    TURNSocket *turnSocket = [[TURNSocket alloc] initWithStream:xmppStream incomingTURNRequest:iq];
    [turnSockets addObject:turnSocket];
    [turnSocket startWithDelegate:self delegateQueue:dispatch_get_main_queue()];
    [turnSocket release];
    }
    return YES;
    }
  • 设置并调用TURNSocket(发送方)
    TURNSocket *turnSocket = [[TURNSocket alloc] initWithStream:[self xmppStream] toJID:user.primaryResource.jid];
    [turnSockets addObject:turnSocket];
    [turnSocket startWithDelegate:self delegateQueue:dispatch_get_main_queue()];
    [turnSocket release];
  • didSucceed同时调用了(发送者和接收者)
    - (void)turnSocket:(TURNSocket *)sender didSucceed:(GCDAsyncSocket *)socket {

  • 发送文件?发件人
    - (void)turnSocket:(TURNSocket *)sender didSucceed:(GCDAsyncSocket *)socket {

    NSData *dataF = [[NSData alloc] initWithContentsOfFile:
    [[NSBundle mainBundle] pathForResource:@"a1" ofType:@"png"]];

    [socket writeData:dataF withTimeout:60.0f tag:0];
    }

    或者:在这里收到数据? (接收方)
    - (void)turnSocket:(TURNSocket *)sender didSucceed:(GCDAsyncSocket *)socket {

    NSData *dataF = [[NSData alloc] init];

    [socket readDataToData:dataF withTimeout:30.0 tag:0];
    NSLog(@"dataF: %d", [dataF length]); // dataF: 0
    }

  • 有谁知道这是什么问题?

    非常感谢!

    最佳答案

    要设置外部IP地址,您需要使用xmpp.proxy.externalip而不是xmpp.externalip

    关于ios - XMPPFramework-TURNSocket无法接收到我自己发送的数据吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8877864/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com