Quantcast
Channel: Ignite Realtime : Unanswered Discussions - Support
Viewing all articles
Browse latest Browse all 4979

Problem in receiving streaminitialization(si) data in IQ packet using asmack android

$
0
0

          In my chat application I use following function for send file information in si tag in IQ which is done successfully,but on get response I don't get si tag in IQ packet instead of that client send me respond with  si tag in IQ packet like that,

 

<iq xmlns="jabber:client" type="result" id="474BB437-B57B-4EC2-8066-88BF4DC02BAE" from="sender_id" to="receiver_id"><si xmlns="http://jabber.org/protocol/si" id="A8905C1F-5217-4550-8BB2-92D28C8A2FD4"><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><globalid>A8905C1F-5217-4550-8BB2-92D28C8A2FD4</gl obalid></si><globalid>A8905C1F-5217-4550-8BB2-92D28C8A2FD4</globalid></iq>

 

// My IQ which I get in response

 

<iq xmlns="jabber:client" type="result" id="474BB437-B57B-4EC2-8066-88BF4DC02BAE" from="sender_id" to="receiver_id">A8905C1F-5217-4550-8BB2-92D28C8A2FD4</iq>

 

 

//method which I used for file information send

public void sendfile(String filenm,String filereceiverid,int filesize,String myid)

    {

        String onlyfilenm = " ";

 

                 StreamInitiation si = new StreamInitiation();

                

                 String filename=filenm.substring(filenm.lastIndexOf("/")+1);

                   

                    si.setMimeType(URLConnection.guessContentTypeFromName(filename));

                    StreamInitiation.File siFile = new StreamInitiation.File(filename,filesize);

                

                    si.setFile(siFile);

               

                    si.setFeatureNegotiationForm(createDefaultInitiationForm());

                    si.setFrom(connection.getUser());

                    si.setTo(filereceiverid + "@chat.bobl.us/" + filereceiverid);

                    si.setType(IQ.Type.SET);

                   

                    UUID uuid = UUID.randomUUID();

                    String uuidInString = uuid.toString();

                    si.setSesssionID(uuidInString);

                 

                    PacketCollector collector = connection

                            .createPacketCollector(new PacketIDFilter(si.getPacketID()));

                    connection.sendPacket(si);   

                   

//Here I get receiver response IQ

 

                    Packet siResponse = collector.nextResult(SmackConfiguration.getPacketReplyTimeout())                   

 

                    if (siResponse instanceof IQ) {

                   

                        IQ iqResponse = (IQ) siResponse;

                        if (iqResponse.getType().equals(IQ.Type.RESULT)) {

                            StreamInitiation response = (StreamInitiation) siResponse;

                           

                            System.out.println("response result" + iqResponse.toXML());

                      

                            try {

                                getOutgoingNegotiator(getStreamMethodField(response

                                        .getFeatureNegotiationForm()));

                            } catch (XMPPException e) {

                                // TODO Auto-generated catch block

                                e.printStackTrace();

                                System.out.println("catch clause call of xmpp senfile method");

                            }

                            }

                        else if (iqResponse.getType().equals(IQ.Type.ERROR)) {

                            throw new XMPPException(iqResponse.getError());

                         

                        }

                        else {

                            throw new XMPPException("File transfer response unreadable");

                        }

                    }           

       

    }

          How I solve this problem , can anyone help me?


Viewing all articles
Browse latest Browse all 4979

Trending Articles