I tried implementing the flash connection into jive but up to now I wasn’'t very sucessful. I write down everyting I know now and maybe somone can help me further:
The startpoint in jive is +SocketReadThread +, I can create a session by adding the following code: see private void createSession().
The next step is that the flash client sends his authorisation request. Startpoint is as well SocketReadThread, this time method readStream(). ReadStream gets the packet but throws an exception on if (eventType == XMLStreamConstants.END_DOCUMENT) and the connection gets dropped
It looks like that the xml-parser that is used doesnt like the flash termination that looks like that “\000”. As the parser is out of the sun webservice project I think is is not a good idea to change someting over there.
My idea, is to capture the stream bevore he is passed to the xml-parser to get rid of the flash termination. The place to do this is in the run method of the same class: xpp = xppFactory.createXMLStreamReader(new InputStreamReader(sock.getInputStream()));
Any idea how I can filter out those “\000” bevor passing to the parser?
Many thanks!
guido
private void createSession() throws UnauthorizedException, XMLStreamException {
for (int eventType = xpp.getEventType();
eventType != XMLStreamConstants.START_ELEMENT;
eventType = xpp.next()) {
}
// Conduct error checking, the opening tag should be ‘‘stream’’
// in the ‘‘etherx’’ namespace
if (!xpp.getLocalName().equals(“stream”) && !xpp.getLocalName().equals(“flash”)) {
throw new XMLStreamException(LocaleUtils.getLocalizedString(“admin.error.bad-stream”));
}
/*if (!xpp.getNamespaceURI(xpp.getPrefix()).equals(ETHERX_NAMESPACE)) {
throw new XMLStreamException(LocaleUtils.getLocalizedString(“admin.error.bad-namespace”)) ;
}*/
XMLStreamWriter xser = connection.getSerializer();
xser.writeStartDocument();
if(xpp.getPrefix().equals(“flash”)){
xser.writeStartElement("flash", "stream", "http://www.jabber.com/streams/flash");
xser.writeNamespace("flash", "http://www.jabber.com/streams/flash");
xser.writeNamespace("stream", "http://etherx.jabber.org/streams");
}else{
xser.writeStartElement(“stream”, “stream”, “http://etherx.jabber.org/streams”);
xser.writeNamespace("stream", "http://etherx.jabber.org/streams");
}
//xser.writeStartElement("stream", "stream", "http://etherx.jabber.org/streams");
//xser.writeNamespace("stream", "http://etherx.jabber.org/streams");
xser.writeDefaultNamespace(“jabber:client”);
xser.writeAttribute(“from”, serverName);
xser.writeAttribute(“id”, session.getStreamID().toString());
if(xpp.getPrefix().equals(“flash”)){
xser.writeCharacters("\0");
}else{
xser.writeCharacters(" ");
}
//xser.writeCharacters(" ");
xser.flush();
// TODO: check for SASL support in opening stream tag
}