Java 类org.jivesoftware.smack.packet.StreamOpen 实例源码

项目:Smack    文件:XMPPTCPConnection.java   
/**
 * Resets the parser using the latest connection's reader. Reseting the parser is necessary
 * when the plain connection has been secured or when a new opening stream element is going
 * to be sent by the server.
 *
 * @throws SmackException if the parser could not be reset.
 */
void openStream() throws SmackException {
    // If possible, provide the receiving entity of the stream open tag, i.e. the server, as much information as
    // possible. The 'to' attribute is *always* available. The 'from' attribute if set by the user and no external
    // mechanism is used to determine the local entity (user). And the 'id' attribute is available after the first
    // response from the server (see e.g. RFC 6120 § 9.1.1 Step 2.)
    CharSequence to = getServiceName();
    CharSequence from = null;
    CharSequence localpart = config.getUsername();
    if (localpart != null) {
        from = XmppStringUtils.completeJidFrom(localpart, to);
    }
    String id = getStreamId();
    // 发送一个SteamOpen
    send(new StreamOpen(to, from, id));
    try {
        packetReader.parser = PacketParserUtils.newXmppParser(reader);
    }
    catch (XmlPullParserException e) {
        throw new SmackException(e);
    }
}
项目:androidclient    文件:XMPPTCPConnection.java   
/**
 * Resets the parser using the latest connection's reader. Reseting the parser is necessary
 * when the plain connection has been secured or when a new opening stream element is going
 * to be sent by the server.
 *
 * @throws SmackException if the parser could not be reset.
 * @throws InterruptedException
 */
void openStream() throws SmackException, InterruptedException {
    // If possible, provide the receiving entity of the stream open tag, i.e. the server, as much information as
    // possible. The 'to' attribute is *always* available. The 'from' attribute if set by the user and no external
    // mechanism is used to determine the local entity (user). And the 'id' attribute is available after the first
    // response from the server (see e.g. RFC 6120 § 9.1.1 Step 2.)
    CharSequence to = getXMPPServiceDomain();
    CharSequence from = null;
    CharSequence localpart = config.getUsername();
    if (localpart != null) {
        from = XmppStringUtils.completeJidFrom(localpart, to);
    }
    String id = getStreamId();
    sendNonza(new StreamOpen(to, from, id));
    try {
        packetReader.parser = PacketParserUtils.newXmppParser(reader);
    }
    catch (XmlPullParserException e) {
        throw new SmackException(e);
    }
}