usa que país pais lada donde código codigo ios xcode ios5 xmpp xmppframework

ios - que - de donde es la lada 503 en usa



Problemas para crear la habitación xmpp muc: Código 503(servicio no disponible) (1)

Mi código para crear una habitación:

XMPPRoomCoreDataStorage *rosterstorage = [[XMPPRoomCoreDataStorage alloc] init]; XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:rosterstorage jid:[XMPPJID jidWithString:@"[email protected]/groupchat"] dispatchQueue:dispatch_get_main_queue()]; [xmppRoom activate:[[self appDelegate] xmppStream]]; if ([xmppRoom preJoinWithNickname:@"nameToCreateRoom"]) { NSLog(@"room created"); [xmppRoom joinRoomUsingNickname:self.userName history:nil]; } [xmppRoom fetchConfigurationForm]; [xmppRoom configureRoomUsingOptions:nil]; [xmppRoom addDelegate:[self appDelegate] delegateQueue:dispatch_get_main_queue()];

Depurar:

2012-08-03 07:46:29.204 iPhoneXMPP[9887:fb03] room created 2012-08-03 07:46:29:230 iPhoneXMPP[9887:15003] SEND: <iq type="get" to="[email protected]" id="B793062B-0E09-492F-BC0F-703503AAA664"><query xmlns="http://jabber.org/protocol/muc#owner"/></iq> 2012-08-03 07:46:29:237 iPhoneXMPP[9887:15003] SEND: <iq type="set" to="[email protected]" id="392D5BFC-707B-4F68-A829-56F949F4E96D"><query xmlns="http://jabber.org/protocol/muc#owner"><x xmlns="jabber:x:data" type="submit"/></query></iq> 2012-08-03 07:46:29:326 iPhoneXMPP[9887:14f03] SEND: <presence to="[email protected]"><x xmlns="http://jabber.org/protocol/muc"/><x xmlns="vcard-temp:x:update"><photo>91217a961321f8f6380ea2feefd0632353ad296c</photo></x><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://code.google.com/p/xmppframework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4="/></presence> 2012-08-03 07:46:29:327 iPhoneXMPP[9887:14f03] RECV: <iq xmlns="jabber:client" from="[email protected]" to="[email protected]/41068195801343976386548353" type="error" id="B793062B-0E09-492F-BC0F-703503AAA664"><query xmlns="http://jabber.org/protocol/muc#owner"/><error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq> 2012-08-03 07:46:29:343 iPhoneXMPP[9887:fb03] iPhoneXMPPAppDelegate: xmppStream:didReceiveIQ: 2012-08-03 07:46:29:421 iPhoneXMPP[9887:15003] RECV: <iq xmlns="jabber:client" from="[email protected]" to="[email protected]/41068195801343976386548353" type="error" id="392D5BFC-707B-4F68-A829-56F949F4E96D"><query xmlns="http://jabber.org/protocol/muc#owner"><x xmlns="jabber:x:data" type="submit"/></query><error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq> 2012-08-03 07:46:29:440 iPhoneXMPP[9887:fb03] iPhoneXMPPAppDelegate: xmppStream:didReceiveIQ:

Veo que está creando / uniendo [email protected] y no [email protected]/groupchat como lo especifiqué. Leí que este es probablemente el problema. Sin embargo, he especificado para el jid completo, entonces estoy perdido.

Gracias de antemano a todos los que ayudan.


Primero, mira aquí XEP-0045: Chat multiusuario .
Como puede ver, primero debe descubrir qué capacidades tiene su usuario (XMPPJID) en el servidor Jabber.

Para hacer esto, envíe el siguiente comando a su Servidor Jabber:

<iq from=''[email protected]/resource'' id=''some_expression'' to=''jabber.server.com'' type=''get''> <query xmlns=''http://jabber.org/protocol/disco#items''/> </iq>

o escrito en objetivo-c usando las funciones de la biblioteca XMPP:

NSError *error = nil; NSXMLElement *query = [[NSXMLElement alloc] initWithXMLString:@"<query xmlns=''http://jabber.org/protocol/disco#items''/>" error:&error]; XMPPIQ *iq = [XMPPIQ iqWithType:@"get" to:[XMPPJID jidWithString:@"jabber.server.com"] elementID:[xmppStream generateUUID] child:query]; [xmppStream sendElement:iq];

Ahora escucha la respuesta del servidor en el delegado XMPPStream - (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq y la respuesta del servidor debería ser algo como esto:

<iq from=''jabber.server.com'' id=''some_expression'' to=''[email protected]/resource'' type=''result''> <query xmlns=''http://jabber.org/protocol/disco#items''> <item jid=''im.jabber.server.com'' name=''Instant Message Service''/> <item jid=''conference.jabber.server.com'' name=''Chatroom Service''/> </query> </iq>

o objetivo c:

- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq { if([iq isResultIQ]) { if([iq elementForName:@"query" xmlns:@"http://jabber.org/protocol/disco#items"]) { NSLog(@"Jabber Server''s Capabilities: %@", [iq XMLString]); } } }

Ahora, para cada artículo devuelto, envíe IQ a su servidor por sus propiedades y descubra cuál es el tipo de conferencia , algo como esto:

<iq from=''[email protected]/resource'' id=''some_expression'' to=''conference.jabber.server.com'' type=''get''> <query xmlns=''http://jabber.org/protocol/disco#info''/> </iq>

o en el objetivo c:

- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq { if([iq isResultIQ]) { if([iq elementForName:@"query" xmlns:@"http://jabber.org/protocol/disco#items"]) { NSXMLElement *query = [iq childElement]; NSArray *items = [query children]; for(NSXMLElement *item in items) { NSError *error = nil; NSXMLElement *sendQuery = [[NSXMLElement alloc] initWithXMLString:@"<query xmlns=''http://jabber.org/protocol/disco#info''/>" error:&error]; XMPPIQ *sendIQ = [XMPPIQ iqWithType:@"get" to:[XMPPJID jidWithString:[item attributeStringValueForName:@"jid"]] elementID:[xmppStream generateUUID] child:sendQuery]; [xmppStream sendElement:sendIQ]; } } } }

Escuche las respuestas del servidor:

<iq from=''conference.jabber.server.com'' id=''some_expression'' to=''[email protected]/resource'' type=''result''> <query xmlns=''http://jabber.org/protocol/disco#info''> <identity category=''conference'' name=''Server Group Chat Service'' type=''text''/> <feature var=''http://jabber.org/protocol/muc''/> </query> </iq>

y tomar el dominio de chat grupal de la identidad con category:conference

- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq { if([iq isResultIQ]) { if([iq elementForName:@"query" xmlns:@"http://jabber.org/protocol/disco#items"]) { ... } else if([iq elementForName:@"query" xmlns:@"http://jabber.org/protocol/disco#info"]) { NSXMLElement *query = [iq childElement]; NSXMLElement *identity = [query elementForName:@"identity"]; if([[identity attributeStringValueForName:@"category"] isEqualToString:@"conference"]) { groupChatDomain = [iq fromStr]; } } } }

Finalmente, cuando tenemos el dominio de chat grupal, podemos crear una sala de chat como esta:

XMPPJID *chatRoomJID = [XMPPJID jidWithUser:@"chat_room" domain:groupChatDomain resource:@"user"]; XMPPRoomMemoryStorage *roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init]; XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:roomMemoryStorage jid:roomChatJID dispatchQueue:dispatch_get_main_queue()]; [xmppRoom activate:xmppStream]; [xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()]; [xmppRoom joinRoomUsingNickname:user history:nil];

y agregue el protocolo <XMPPRoomDelegate> en su controlador de vista y sus delegados:

- (void)xmppRoomDidCreate:(XMPPRoom *)sender - (void)xmppRoomDidDestroy:(XMPPRoom *)sender - (void)xmppRoom:(XMPPRoom *)sender didConfigure:(XMPPIQ *)iqResult - (void)xmppRoom:(XMPPRoom *)sender didNotConfigure:(XMPPIQ *)iqResult - (void)xmppRoomDidJoin:(XMPPRoom *)sender - (void)xmppRoomDidLeave:(XMPPRoom *)sender - (void)xmppRoom:(XMPPRoom *)sender occupantDidJoin:(XMPPJID *)occupantJID withPresence:(XMPPPresence *)presence - (void)xmppRoom:(XMPPRoom *)sender occupantDidLeave:(XMPPJID *)occupantJID withPresence:(XMPPPresence *)presence - (void)xmppRoom:(XMPPRoom *)sender didReceiveMessage:(XMPPMessage *)message fromOccupant:(XMPPJID *)occupantJID

Nota: antes de invitar a otros usuarios a la sala de chat, debe enviar y confirmar las configuraciones de la sala (se puede invitar a otros usuarios pero no se pueden enviar mensajes).
Entonces puede hacer esto después de que se crea Room (delegate - (void)xmppRoomDidCreate:(XMPPRoom *)sender se llama al - (void)xmppRoomDidCreate:(XMPPRoom *)sender ) o su usuario se ha unido (delegate - (void)xmppRoomDidJoin:(XMPPRoom *)sender se llama al - (void)xmppRoomDidJoin:(XMPPRoom *)sender ) a Chat Room.

Para enviar y confirmar la configuración de la sala, realice una de las siguientes acciones:

- (void)xmppRoomDidCreate:(XMPPRoom *)sender { [sender configureRoomUsingOptions:nil]; }

o

- (void)xmppRoomDidJoin:(XMPPRoom *)sender { [sender configureRoomUsingOptions:nil]; }

Envíe nil para aceptar opciones predeterminadas o puede enviar IQ con sintaxis de la siguiente manera a su servidor:

<iq type=''set'' from=''[email protected]/resource'' id=''some_expression'' to=''[email protected]''> <query xmlns=''http://jabber.org/protocol/muc#owner''> <x xmlns=''jabber:x:data'' type=''submit''> <field var=''FORM_TYPE''> <value>http://jabber.org/protocol/muc#roomconfig</value> </field> <field var=''muc#roomconfig_roomname''> <value>My Chat Room</value> </field> . . . <x> </query> </iq>

o codigo objetivo c:

NSError *error = nil; NSXMLElement *query = [[NSXMLElement alloc] initWithXMLString:@"<query xmlns=''http://jabber.org/protocol/muc#owner''/>" error:&error]; NSXMLElement *x = [NSXMLElement elementWithName:@"x" xmlns:@"jabber:x:data"]; [x addAttributeWithName:@"type" stringValue:@"submit"]; NSXMLElement *field1 = [NSXMLElement elementWithName:@"field"]; [field1 addAttributeWithName:@"var" stringValue:@"FORM_TYPE"]; NSXMLElement *value1 = [NSXMLElement elementWithName:@"value" stringValue:@"http://jabber.org/protocol/muc#roomconfig"]; [field1 addChild:value1]; NSXMLElement *field2 = [NSXMLElement elementWithName:@"field"]; [field2 addAttributeWithName:@"var" stringValue:@"muc#roomconfig_roomname"]; NSXMLElement *value2 = [NSXMLElement elementWithName:@"value" stringValue:@"My Chat Room"]; [field2 addChild:value2]; //Add other fields you need, just like field1 and field2 [x addChild:field1]; [x addChild:field2]; [query addChild:x]; NSXMLElement *roomOptions = [NSXMLElement elementWithName:@"iq"]; [roomOptions addAttributeWithName:@"type" stringValue:@"set"]; [roomOptions addAttributeWithName:@"id" stringValue:[xmppStream generateUUID]; [roomOptions addAttributeWithName:@"to" stringValue:@"[email protected]"]; [roomOptions addChild:query]; [sender configureRoomUsingOptions:roomOptions];

y la lista de todos los posibles campos de Formulario de configuración está aquí