xmpp 文件 傳輸 協議 筆記 简体版
原文   原文鏈接
-(void)queryNextProxy0096{
    XMPPLogTrace();
    state = STATE_PROXY_DISCO_0096;
//    <iq type='set' id='offer1' to='receiver@domainopenfire/Spark 2.6.3'' from="">
//      <si xmlns='http://jabber.org/protocol/si'
//             id='uuid'
//              mime-type='text/plain'
//                  profile='http://jabber.org/protocol/si/profile/file-transfer'>
//          <file xmlns='http://jabber.org/protocol/si/profile/file-transfer'
//              name='test.txt'
//                  size='1022''>
//              <desc>This is a test. If this were a real file...</desc>
//          </file>
//          <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>
//                      <option><value>http://jabber.org/protocol/ibb</value></option>
//                  </field>
//              </x>
//          </feature>
//      </si>
//    </iq>
    XMPPJID *xmppJid = nil;
    xmppJid = jid;
    XMPPIQ *iq  ;
    
    NSXMLElement *si = [NSXMLElement elementWithName:@"si" xmlns:@"http://jabber.org/protocol/si"];
    [si addAttributeWithName:@"id" stringValue:uuid];
    [si addAttributeWithName:@"mime-type" stringValue:@"text/plain"];
    [si addAttributeWithName:@"profile" stringValue:@"http://jabber.org/protocol/si/profile/file-transfer"];
    
    NSXMLElement *file = [NSXMLElement elementWithName:@"file" xmlns:@"http://jabber.org/protocol/si/profile/file-transfer"];
    [file addAttributeWithName:@"name" stringValue:[sendFileDic objectForKey:@"name"]];
    [file addAttributeWithName:@"size" stringValue:[sendFileDic objectForKey:@"size"]];
    NSXMLElement *des = [NSXMLElement elementWithName:@"desc" stringValue:@"test"];
    [file addChild:des];
    
    NSXMLElement *feature = [NSXMLElement elementWithName:@"feature" xmlns:@"http://jabber.org/protocol/feature-neg"];
    NSXMLElement *x = [NSXMLElement elementWithName:@"x" xmlns:@"jabber:x:data"];
    [x addAttributeWithName:@"type" stringValue:@"form"];
    NSXMLElement *field = [NSXMLElement elementWithName:@"field"];
    [field addAttributeWithName:@"var" stringValue:@"stream-method"];
    [field addAttributeWithName:@"type" stringValue:@"list-single"];
    NSXMLElement *option1 = [NSXMLElement elementWithName:@"option"];
    NSXMLElement *value1 = [NSXMLElement elementWithName:@"value" stringValue:@"http://jabber.org/protocol/bytestreams"];
    [option1 addChild:value1];
    [field addChild:option1];
    
    NSXMLElement *option2 = [NSXMLElement elementWithName:@"option"];
    NSXMLElement *value2 = [NSXMLElement elementWithName:@"value" stringValue:@"http://jabber.org/protocol/ibb"];
    [option2  addChild:value2];
    [field addChild:option2];
    
    [x addChild:field];
    [feature addChild:x];
    [si addChild:file];
    [si addChild:feature];
    [self updateDiscoUUID];
    iq = [XMPPIQ iqWithType:@"set" to:jid elementID:discoUUID child:si];
    [iq addAttributeWithName:@"from" stringValue:[xmppStream.myJID full]] ;
    [xmppStream sendElement:iq];
}
相關文章
相關標籤/搜索
每日一句
    每一个你不满意的现在,都有一个你没有努力的曾经。
本站公眾號
   歡迎關注本站公眾號,獲取更多信息