XMPP with Java Asmack library supporting X-FACEBOOK-PLATFORM

Finally, thanks to the no.good.at.coding code and the suggestion of harism, I’ve been able to connect to the Facebook chat. This code is the Mechanism for the Asmack library (the Smack port for Android). For the Smack library is necessary to use the no.good.at.coding mechanism. SASLXFacebookPlatformMechanism.java: import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.security.MessageDigest; import … Read more

XMPPFramework – How to create a MUC room and invite users?

After exploring various solutions, I’ve decided to compile and share my implementation here: Create an XMPP Room: XMPPRoomMemoryStorage *roomStorage = [[XMPPRoomMemoryStorage alloc] init]; /** * Remember to add ‘conference’ in your JID like this: * e.g. [email protected] */ XMPPJID *roomJID = [XMPPJID jidWithString:@”[email protected]”]; XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:roomStorage jid:roomJID dispatchQueue:dispatch_get_main_queue()]; [xmppRoom activate:[self appDelegate].xmppStream]; [xmppRoom … Read more

XMPPFramework – Implement Group Chat (MUC)

to get a list of rooms: NSString* server = @”chat.shakespeare.lit”; //or whatever the server address for muc is XMPPJID *servrJID = [XMPPJID jidWithString:server]; XMPPIQ *iq = [XMPPIQ iqWithType:@”get” to:servJID]; [iq addAttributeWithName:@”from” stringValue:[xmppStream myJID].full]; NSXMLElement *query = [NSXMLElement elementWithName:@”query”]; [query addAttributeWithName:@”xmlns” stringValue:@”http://jabber.org/protocol/disco#items”]; [iq addChild:query]; [xmppStream sendElement:iq]; check for response in delegate method: – (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ … Read more

JAXB marshalling XMPP stanzas

How about the following?: Create a custom XMLStreamWriter that will treat all namespace declarations as default namespaces, and then marshal to that: ByteArrayOutputStream baos = new ByteArrayOutputStream(); XMLOutputFactory xof = XMLOutputFactory.newFactory(); XMLStreamWriter xsw = xof.createXMLStreamWriter(System.out); xsw = new MyXMLStreamWriter(xsw); m.marshal(iq, xsw); xsw.close(); MyXMLStreamWriter import java.util.Iterator; import javax.xml.namespace.NamespaceContext; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; public class MyXMLStreamWriter implements … Read more