【发布时间】:2025-12-07 17:20:02
【问题描述】:
我有两个问题:
-
我有一个使用 Xcode 在 Objective-C 中开发的 jabber 客户端,并且我安装了一个 Openfire 服务器。
当我运行服务器时,两个客户端将连接。第一个 - 我的 jabber 客户端:一个 spark IM 客户端,第二个 - 我的 iPhone 应用程序。沟通没有问题。我唯一的问题在于进行图像传输时。
代码如下:
- (void)viewDidLoad { [super viewDidLoad]; self.tView.delegate = self; self.tView.dataSource = self; [self.tView setSeparatorStyle:UITableViewCellSeparatorStyleNone]; messages = [[NSMutableArray alloc ] init]; JabberClientAppDelegate *del = [self appDelegate]; del._messageDelegate = self; [self.messageField becomeFirstResponder]; XMPPJID *jid = [XMPPJID jidWithString:chatWithUser]; NSLog(@"Attempting TURN connection to %@", jid); TURNSocket *turnSocket = [[TURNSocket alloc] initWithStream:[self xmppStream] toJID:jid]; [turnSockets addObject:turnSocket]; [turnSocket startWithDelegate:self delegateQueue:dispatch_get_main_queue()]; [turnSocket release]; } - (void)turnSocket:(TURNSocket *)sender didSucceed:(GCDAsyncSocket *)socket { NSLog(@"TURN Connection succeeded!"); NSLog(@"You now have a socket that you can use to send/receive data to/from the other person."); [turnSockets removeObject:sender]; } - (void)turnSocketDidFail:(TURNSocket *)sender { NSLog(@"TURN Connection failed!"); [turnSockets removeObject:sender]; }我不知道是因为两者都使用相同的 IP 并尝试连接到具有相同 IP 的服务器,还是 Openfire 服务器上的某些东西被禁用。
现在是第二个问题……
-
为了解决第一个问题,我在另一台计算机上安装了 Openfire 服务器。在高级设置的 spark 客户端中,我将传递 IP(IP 是一个 nat 地址,192.168...)和端口以及服务器的名称。
但在我的 iPhone 应用程序中,它无法连接。我怎样才能建立连接?在本地主机中,它运行完美。我尝试更改主机名称等,但无济于事。
有人可以帮我吗?
附:我必须在 OpenFire Server 中做什么才能允许数据传输?
【问题讨论】:
-
您已提出 7 个问题,但尚未接受任何答案。这导致没有用户愿意回答您的问题,您将开始获得越来越少的帮助。
-
请不要使用 Pastie 来托管您的代码。在您的问题中嵌入它或您拥有的任何图像。此外,Xcode 只是一个 IDE,因此它与您的问题没有任何关系。
-
嗨,哈维。你的 TURNSocket 工作了吗?
标签: ios objective-c xmpp openfire