- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我已经使用本教程实现了一些文件传输代码:
以及我正在使用的代码:
- (void)sendToOtherDevice:(NSData *)fileData receiverJid:(NSString *)receiverJid
{
XMPPJID *jid = [XMPPJID jidWithString:receiverJid];
XMPPSIFileTransfer *sifiletransfer = [[XMPPSIFileTransfer alloc] init];
[sifiletransfer initiateFileTransferTo:jid withData:fileData];
NSString *s = [NSString stringWithFormat:@"%@/spark",receiverJid];
NSString *jabbarID = [[[[self appDelegate] xmppStream] myJID] bare];
XMPPJID *senderjid = [XMPPJID jidWithString:jabbarID];
//[TURNSocket setProxyCandidates:[NSArray arrayWithObjects:s, nil]];
// [TURNSocket setProxyCandidates:[NSArray arrayWithObjects:s,jabbarID, nil]];
[TURNSocket setProxyCandidates:[NSArray arrayWithObjects:jid.domain,senderjid.domain, nil]];
// [TURNSocket setProxyCandidates:[NSArray arrayWithObjects:jid.domain, nil]];
//[TURNSocket setProxyCandidates:[NSArray arrayWithObjects:@"111.11.111.111", nil]];
TURNSocket *socket1 = [[TURNSocket alloc] initWithStream:[self xmppStream] toJID:jid];
// [turnSockets addObject:turnSocket];
[socket1 startWithDelegate:self delegateQueue:dispatch_get_main_queue()];
}
-(void)turnSocket:(TURNSocket *)sender didSucceed:(GCDAsyncSocket *)socket
{
[socket writeData:photoData withTimeout:60.0f tag:0];
[socket disconnectAfterWriting];
}
- (void)turnSocketDidFail:(TURNSocket *)sender
{
NSLog(@"Couldn't set up bytestream for file transfer!");
}
然后在运行这段代码时我会得到以下 XMLStangas:
在android端接收日志:
12-03 10:26:59.359: D/SMACK(2021): 10:26:59 AM RCV (1095046240): <iq type="set" id="47198142-86E8-41E2-9F68-40C52AFD5469" to="kadhirkarbonn@ip-10-123-60-876/smack" from="kadhirsduos@ip-10-123-60-876/smack"><si xmlns="http://jabber.org/protocol/si" id="A0E740DE-CDF1-408E-ABE1-8F582A615F1E" mime-type="image/jpg" profile="http://jabber.org/protocol/si/profile/file-transfer"><file xmlns="http://jabber.org/protocol/si/profile/file-transfer" name="4_9.jpg" size="75261"/><feature xmlns="http://jabber.org/protocol/feature-neg"><x xmlns="jabber:x:data" type="form"><field var="stream-method" type="list-single"><option><value>http://jabber.org/protocol/bytestreams</value></option></field></x></feature></si></iq>
12-03 10:26:59.399: I/Insert(2021): insert data with file name ===========4_9.jpg
12-03 10:27:01.749: I/Kadhir(2021): 4_9.jpg downloading started
12-03 10:27:01.779: D/SMACK(2021): 10:27:01 AM SENT (1095046240): <iq id="47198142-86E8-41E2-9F68-40C52AFD5469" to="kadhirsduos@ip-10-123-60-876/smack" from="kadhirkarbonn@ip-10-123-60-876/smack" type="result"><si xmlns="http://jabber.org/protocol/si"><feature xmlns="http://jabber.org/protocol/feature-neg"><x xmlns="jabber:x:data" type="submit"><field var="stream-method"><value>http://jabber.org/protocol/bytestreams</value></field></x></feature></si></iq>
12-03 10:27:02.039: D/SMACK(2021): 10:27:02 AM RCV (1095046240): <iq type="get" id="ECF5E292-013C-45E5-8053-E2EA86219622" to="kadhirkarbonn@ip-10-123-60-876/smack" from="kadhirsduos@ip-10-123-60-876/smack"><query xmlns="http://jabber.org/protocol/disco#info"/></iq>
12-03 10:27:02.049: D/SMACK(2021): 10:27:02 AM SENT (1095046240): <iq id="ECF5E292-013C-45E5-8053-E2EA86219622" to="kadhirsduos@ip-10-123-60-876/smack" type="result"><query xmlns="http://jabber.org/protocol/disco#info"><identity category="client" name="quytech" type="phone"/><feature var="http://jabber.org/protocol/caps"/><feature var="http://jabber.org/protocol/disco#info"/><feature var="jabber:iq:privacy"/><feature var="http://jabber.org/protocol/si"/><feature var="http://jabber.org/protocol/bytestreams"/><feature var="http://jabber.org/protocol/ibb"/><feature var="http://jabber.org/protocol/si/profile/file-transfer"/><feature var="http://jabber.org/protocol/si"/><feature var="http://jabber.org/protocol/bytestreams"/><feature var="http://jabber.org/protocol/ibb"/><feature var="http://jabber.org/protocol/si/profile/file-transfer"/><feature var="http://jabber.org/protocol/si"/><feature var="http://jabber.org/protocol/bytestreams"/><feature var="http://jabber.org/protocol/ibb"/></query></iq>
12-03 10:27:02.739: D/SMACK(2021): 10:27:02 AM RCV (1095046240): <iq type="set" to="kadhirkarbonn@ip-10-123-60-876/smack" id="E5132784-1493-458B-98B0-8E3902A541C0" from="kadhirsduos@ip-10-123-60-876/smack"><query xmlns="http://jabber.org/protocol/bytestreams" sid="A0E740DE-CDF1-408E-ABE1-8F582A615F1E" mode="tcp"><streamhost jid="kadhirsduos@ip-10-123-60-876/smack" host="127.0.0.1" port="7777"/><streamhost jid="proxy.ip-10-123-60-876" host="10.123.60.876" port="7777"/></query></iq>
12-03 10:30:02.759: D/SMACK(2021): 10:30:02 AM RCV (1095046240): <iq type="get" id="863-206317" from="ip-10-123-60-876" to="kadhirkarbonn@ip-10-123-60-876/smack"><ping xmlns="urn:xmpp:ping"/></iq>
12-03 10:30:02.779: D/SMACK(2021): 10:30:02 AM SENT (1095046240): <iq id="863-206317" to="ip-10-123-60-876" from="kadhirkarbonn@ip-10-123-60-876/smack" type="error"><error code="501" type="CANCEL"><feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
12-03 10:30:12.259: D/SMACK(2021): 10:30:12 AM SENT (1095046240): <iq id="E5132784-1493-458B-98B0-8E3902A541C0" to="kadhirsduos@ip-10-123-60-876/smack" from="kadhirkarbonn@ip-10-123-60-876/smack" type="error"><error code="406" type="MODIFY"><not-acceptable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><text xml:lang="en" xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Could not establish socket with any provided host</text></error></iq>
IOS端发送日志:
2013-12-03 10:21:41:731 iPhoneXMPP[525:3523] SEND: <message type="chat" to="kadhirkarbonn@ip-10-123-60-876"><body>enter message here..</body></message>
2013-12-03 10:21:53.987 iPhoneXMPP[525:a0b] Sender ID is ==== kadhirsduos@ip-10-123-60-876/smack
2013-12-03 10:21:53:990 iPhoneXMPP[525:3523] SEND: <iq type="set" id="47198142-86E8-41E2-9F68-40C52AFD5469" to="kadhirkarbonn@ip-10-123-60-876/smack" from="kadhirsduos@ip-10-123-60-876/smack"><si xmlns="http://jabber.org/protocol/si" id="A0E740DE-CDF1-408E-ABE1-8F582A615F1E" mime-type="image/jpg" profile="http://jabber.org/protocol/si/profile/file-transfer"><file xmlns="http://jabber.org/protocol/si/profile/file-transfer" name="4_9.jpg" size="75261"/><feature xmlns="http://jabber.org/protocol/feature-neg"><x xmlns="jabber:x:data" type="form"><field var="stream-method" type="list-single"><option><value>http://jabber.org/protocol/bytestreams</value></option></field></x></feature></si></iq>
2013-12-03 10:21:56:721 iPhoneXMPP[525:5407] RECV: <iq xmlns="jabber:client" id="47198142-86E8-41E2-9F68-40C52AFD5469" to="kadhirsduos@ip-10-123-60-876/smack" from="kadhirkarbonn@ip-10-123-60-876/smack" type="result"><si xmlns="http://jabber.org/protocol/si"><feature xmlns="http://jabber.org/protocol/feature-neg"><x xmlns="jabber:x:data" type="submit"><field var="stream-method"><value>http://jabber.org/protocol/bytestreams</value></field></x></feature></si></iq>
2013-12-03 10:21:56:721 iPhoneXMPP[525:a0b] iPhoneXMPPAppDelegate: xmppStream:didReceiveIQ:
2013-12-03 10:21:56.721 iPhoneXMPP[525:5407] didRecieveIQ*****************
2013-12-03 10:21:56.722 iPhoneXMPP[525:5407] IQ type === result
2013-12-03 10:21:56.723 iPhoneXMPP[525:5407] IQ type === si
2013-12-03 10:21:56.723 iPhoneXMPP[525:5407] IQ type === result/si
2013-12-03 10:21:56:724 iPhoneXMPP[525:5217] SEND: <iq type="get" id="ECF5E292-013C-45E5-8053-E2EA86219622" to="kadhirkarbonn@ip-10-123-60-876/smack" from="kadhirsduos@ip-10-123-60-876/smack"><query xmlns="http://jabber.org/protocol/disco#info"/></iq>
2013-12-03 10:21:56:725 iPhoneXMPP[525:5217] SEND: <iq type="get" to="ip-10-123-60-876" id="41BB64C7-4216-4E7E-BC0F-CAEB7D093D45"><query xmlns="http://jabber.org/protocol/disco#items"/></iq>
2013-12-03 10:21:56:965 iPhoneXMPP[525:5407] RECV: <iq xmlns="jabber:client" type="result" id="41BB64C7-4216-4E7E-BC0F-CAEB7D093D45" from="ip-10-123-60-876" to="kadhirsduos@ip-10-123-60-876/smack"><query xmlns="http://jabber.org/protocol/disco#items"><item jid="search.ip-10-123-60-876" name="User Search"/><item jid="conference.ip-10-123-60-876" name="Public Chatrooms"/><item jid="proxy.ip-10-123-60-876" name="Socks 5 Bytestreams Proxy"/><item jid="pubsub.ip-10-123-60-876" name="Publish-Subscribe service"/></query></iq>
2013-12-03 10:21:56:966 iPhoneXMPP[525:a0b] iPhoneXMPPAppDelegate: xmppStream:didReceiveIQ:
2013-12-03 10:21:56.966 iPhoneXMPP[525:5217] didRecieveIQ*****************
2013-12-03 10:21:56:967 iPhoneXMPP[525:3523] SEND: <iq type="get" to="proxy.ip-10-123-60-876" id="567B54C6-FE53-4A80-9DC6-13AA3E3C5445"><query xmlns="http://jabber.org/protocol/disco#info"/></iq>
2013-12-03 10:21:56.967 iPhoneXMPP[525:5217] IQ type === result
2013-12-03 10:21:57:087 iPhoneXMPP[525:5217] RECV: <iq xmlns="jabber:client" id="ECF5E292-013C-45E5-8053-E2EA86219622" to="kadhirsduos@ip-10-123-60-876/smack" type="result" from="kadhirkarbonn@ip-10-123-60-876/smack"><query xmlns="http://jabber.org/protocol/disco#info"><identity category="client" name="quytech" type="phone"/><feature var="http://jabber.org/protocol/caps"/><feature var="http://jabber.org/protocol/disco#info"/><feature var="jabber:iq:privacy"/><feature var="http://jabber.org/protocol/si"/><feature var="http://jabber.org/protocol/bytestreams"/><feature var="http://jabber.org/protocol/ibb"/><feature var="http://jabber.org/protocol/si/profile/file-transfer"/><feature var="http://jabber.org/protocol/si"/><feature var="http://jabber.org/protocol/bytestreams"/><feature var="http://jabber.org/protocol/ibb"/><feature var="http://jabber.org/protocol/si/profile/file-transfer"/><feature var="http://jabber.org/protocol/si"/><feature var="http://jabber.org/protocol/bytestreams"/><feature var="http://jabber.org/protocol/ibb"/></query></iq>
2013-12-03 10:21:57:088 iPhoneXMPP[525:a0b] iPhoneXMPPAppDelegate: xmppStream:didReceiveIQ:
2013-12-03 10:21:57.089 iPhoneXMPP[525:3523] didRecieveIQ*****************
2013-12-03 10:21:57.090 iPhoneXMPP[525:3523] IQ type === result
2013-12-03 10:21:57:205 iPhoneXMPP[525:3523] RECV: <iq xmlns="jabber:client" type="result" id="567B54C6-FE53-4A80-9DC6-13AA3E3C5445" from="proxy.ip-10-123-60-876" to="kadhirsduos@ip-10-123-60-876/smack"><query xmlns="http://jabber.org/protocol/disco#info"><identity category="proxy" name="SOCKS5 Bytestreams Service" type="bytestreams"/><feature var="http://jabber.org/protocol/bytestreams"/><feature var="http://jabber.org/protocol/disco#info"/></query></iq>
2013-12-03 10:21:57:205 iPhoneXMPP[525:a0b] iPhoneXMPPAppDelegate: xmppStream:didReceiveIQ:
2013-12-03 10:21:57:206 iPhoneXMPP[525:5217] SEND: <iq type="get" to="proxy.ip-10-123-60-876" id="F9F121E4-918C-4437-8B4A-E5568E123F57"><query xmlns="http://jabber.org/protocol/bytestreams"/></iq>
2013-12-03 10:21:57.206 iPhoneXMPP[525:5407] didRecieveIQ*****************
2013-12-03 10:21:57.208 iPhoneXMPP[525:5407] IQ type === result
2013-12-03 10:21:57:325 iPhoneXMPP[525:5407] RECV: <iq xmlns="jabber:client" type="result" id="F9F121E4-918C-4437-8B4A-E5568E123F57" from="proxy.ip-10-123-60-876" to="kadhirsduos@ip-10-123-60-876/smack"><query xmlns="http://jabber.org/protocol/bytestreams"><streamhost jid="proxy.ip-10-123-60-876" host="10.123.60.876" port="7777"/></query></iq>
2013-12-03 10:21:57:326 iPhoneXMPP[525:a0b] iPhoneXMPPAppDelegate: xmppStream:didReceiveIQ:
2013-12-03 10:21:57:327 iPhoneXMPP[525:5407] SEND: <iq type="set" to="kadhirkarbonn@ip-10-123-60-876/smack" id="E5132784-1493-458B-98B0-8E3902A541C0" from="kadhirsduos@ip-10-123-60-876/smack"><query xmlns="http://jabber.org/protocol/bytestreams" sid="A0E740DE-CDF1-408E-ABE1-8F582A615F1E" mode="tcp"><streamhost jid="kadhirsduos@ip-10-123-60-876/smack" host="127.0.0.1" port="7777"/><streamhost jid="proxy.ip-10-123-60-876" host="10.123.60.876" port="7777"/></query></iq>
2013-12-03 10:21:57.326 iPhoneXMPP[525:3523] didRecieveIQ*****************
2013-12-03 10:21:57.329 iPhoneXMPP[525:3523] IQ type === result
2013-12-03 10:23:16.726 iPhoneXMPP[525:a0b] SOCKS5 Connection failed!
2013-12-03 10:25:07:188 iPhoneXMPP[525:3523] RECV: <iq xmlns="jabber:client" id="E5132784-1493-458B-98B0-8E3902A541C0" to="kadhirsduos@ip-10-123-60-876/smack" from="kadhirkarbonn@ip-10-123-60-876/smack" type="error"><error code="406" type="MODIFY"><not-acceptable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" lang="en">Could not establish socket with any provided host</text></error></iq>
2013-12-03 10:25:07:189 iPhoneXMPP[525:a0b] iPhoneXMPPAppDelegate: xmppStream:didReceiveIQ:
2013-12-03 10:25:07.189 iPhoneXMPP[525:3523] didRecieveIQ*****************
在此我从未调用过 turnSocket : didSuccedd 方法。谁能告诉我我错过了什么。请帮忙。
最佳答案
注意:我的 XEP-0096 实现与您的不同。您创建 session 的任何方式,只需获取该 ID它可以帮助您:
- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq
{
//**************** Handling the file transfer task *****************//
NSLog(@"---------- Check if this IQ is for a File Transfer ----------");
NSString *myFileTransferID = YOUR_SESSION_ID_GET_FROM_XEP--0096//[xmppFileTransfer xmppFileTransferResponse:(XMPPIQ *)iq];
if ([myFileTransferID length]>0) {
// Get the file size
NSXMLElement *si = [iq elementForName:@"si"];
NSXMLElement *file = [si elementForName:@"file"];
if (file) {
//All are the attribute of file while creating section Id you need to take car for that
filesize = [file attributeUInt32ValueForName:@"size"];
received_FileOwner = [iq fromStr];
received_FileType = [si attributeStringValueForName:@"mime-type"];
received_FileName = [file attributeStringValueForName:@"name"];
}
}
if([myFileTransferID length] > 0 && [[iq type] isEqualToString:@"result"]) {
// Create bytestream socket for File Transfer via XEP-0065
TURNSocket *turnSocket = [[TURNSocket alloc] initWithStream:xmppStream toJID:[iq from] fileTransferSID:myFileTransferID];
[turnSockets addObject:turnSocket];
[turnSocket startWithDelegate:self delegateQueue:dispatch_get_main_queue()];
}
else if([myFileTransferID length] > 0 && [[iq type] isEqualToString:@"set"]) {
if ([TURNSocket isNewStartTURNRequest:iq]) {
NSLog(@"TURN Connectio started:: to establish:: incoming file transfer request..");
TURNSocket *turnSocket = [[TURNSocket alloc]initWithStream:sender incomingTURNRequest:iq withSessionID:myFileTransferID];
[turnSocket startWithDelegate:self delegateQueue:dispatch_get_main_queue()];
[turnSockets addObject:turnSocket];
}
}
}
TurnSocket 委托(delegate)
- (void)turnSocket:(TURNSocket *)sender didSucceed:(GCDAsyncSocket *)socket
{
NSLog(@"Socket Suceeed Port For File Transfer: %d",socket.localPort);
DDLogInfo(@"TURN Connection succeeded!");
DDLogInfo(@"You now have a socket that you can use to send/receive data to/from the other person.");
if ([imageDataFile length]>0) {
// fileTransferData data to write
[socket fileTransferData withTimeout:200.0f tag:TAG_FILETRANSFER_STREAM];
// [turnSockets removeObject:sender];
}
else {
fileTransferData = [[NSMutableData alloc]init];
[socket readDataToLength:filesize withTimeout:290.0f tag:0];
}
}
- (void)turnSocketDidFail:(TURNSocket *)sender
{
DDLogInfo(@"TURN Connection failed!");
[turnSockets removeObject:sender];
}
- (void)readRecievedData:(NSData*)data withTurnSocket:(TURNSocket *)receiver {
[fileTransferData appendData:data];
float progress = (float)[fileTransferData length] / (float)[data length];
NSLog(@"Progresaa value is: %f",progress);
}
关于ios - 在 ios 中使用 XmppFrameWork 进行文件传输,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20114783/
我需要将文本放在 中在一个 Div 中,在另一个 Div 中,在另一个 Div 中。所以这是它的样子: #document Change PIN
奇怪的事情发生了。 我有一个基本的 html 代码。 html,头部, body 。(因为我收到了一些反对票,这里是完整的代码) 这是我的CSS: html { backgroun
我正在尝试将 Assets 中的一组图像加载到 UICollectionview 中存在的 ImageView 中,但每当我运行应用程序时它都会显示错误。而且也没有显示图像。 我在ViewDidLoa
我需要根据带参数的 perl 脚本的输出更改一些环境变量。在 tcsh 中,我可以使用别名命令来评估 perl 脚本的输出。 tcsh: alias setsdk 'eval `/localhome/
我使用 Windows 身份验证创建了一个新的 Blazor(服务器端)应用程序,并使用 IIS Express 运行它。它将显示一条消息“Hello Domain\User!”来自右上方的以下 Ra
这是我的方法 void login(Event event);我想知道 Kotlin 中应该如何 最佳答案 在 Kotlin 中通配符运算符是 * 。它指示编译器它是未知的,但一旦知道,就不会有其他类
看下面的代码 for story in book if story.title.length < 140 - var story
我正在尝试用 C 语言学习字符串处理。我写了一个程序,它存储了一些音乐轨道,并帮助用户检查他/她想到的歌曲是否存在于存储的轨道中。这是通过要求用户输入一串字符来完成的。然后程序使用 strstr()
我正在学习 sscanf 并遇到如下格式字符串: sscanf("%[^:]:%[^*=]%*[*=]%n",a,b,&c); 我理解 %[^:] 部分意味着扫描直到遇到 ':' 并将其分配给 a。:
def char_check(x,y): if (str(x) in y or x.find(y) > -1) or (str(y) in x or y.find(x) > -1):
我有一种情况,我想将文本文件中的现有行包含到一个新 block 中。 line 1 line 2 line in block line 3 line 4 应该变成 line 1 line 2 line
我有一个新项目,我正在尝试设置 Django 调试工具栏。首先,我尝试了快速设置,它只涉及将 'debug_toolbar' 添加到我的已安装应用程序列表中。有了这个,当我转到我的根 URL 时,调试
在 Matlab 中,如果我有一个函数 f,例如签名是 f(a,b,c),我可以创建一个只有一个变量 b 的函数,它将使用固定的 a=a1 和 c=c1 调用 f: g = @(b) f(a1, b,
我不明白为什么 ForEach 中的元素之间有多余的垂直间距在 VStack 里面在 ScrollView 里面使用 GeometryReader 时渲染自定义水平分隔线。 Scrol
我想知道,是否有关于何时使用 session 和 cookie 的指南或最佳实践? 什么应该和什么不应该存储在其中?谢谢! 最佳答案 这些文档很好地了解了 session cookie 的安全问题以及
我在 scipy/numpy 中有一个 Nx3 矩阵,我想用它制作一个 3 维条形图,其中 X 轴和 Y 轴由矩阵的第一列和第二列的值、高度确定每个条形的 是矩阵中的第三列,条形的数量由 N 确定。
假设我用两种不同的方式初始化信号量 sem_init(&randomsem,0,1) sem_init(&randomsem,0,0) 现在, sem_wait(&randomsem) 在这两种情况下
我怀疑该值如何存储在“WORD”中,因为 PStr 包含实际输出。? 既然Pstr中存储的是小写到大写的字母,那么在printf中如何将其给出为“WORD”。有人可以吗?解释一下? #include
我有一个 3x3 数组: var my_array = [[0,1,2], [3,4,5], [6,7,8]]; 并想获得它的第一个 2
我意识到您可以使用如下方式轻松检查焦点: var hasFocus = true; $(window).blur(function(){ hasFocus = false; }); $(win
我是一名优秀的程序员,十分优秀!