当前位置: 首页>>代码示例>>Java>>正文


Java StanzaType类代码示例

本文整理汇总了Java中org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType的典型用法代码示例。如果您正苦于以下问题:Java StanzaType类的具体用法?Java StanzaType怎么用?Java StanzaType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StanzaType类属于org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager包,在下文中一共展示了StanzaType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType; //导入依赖的package包/类
@Override
public Open parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
    String sessionID = parser.getAttributeValue("", "sid");
    int blockSize = Integer.parseInt(parser.getAttributeValue("", "block-size"));

    String stanzaValue = parser.getAttributeValue("", "stanza");
    StanzaType stanza = null;
    if (stanzaValue == null) {
        stanza = StanzaType.IQ;
    }
    else {
        stanza = StanzaType.valueOf(stanzaValue.toUpperCase(Locale.US));
    }

    parser.next();

    return new Open(sessionID, blockSize, stanza);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:19,代码来源:OpenIQProvider.java

示例2: shouldUseConfiguredStanzaType

import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType; //导入依赖的package包/类
@Test
public void shouldUseConfiguredStanzaType() throws SmackException {
    InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);
    byteStreamManager.setStanza(StanzaType.MESSAGE);

    protocol.addResponse(null, new Verification<Open, IQ>() {

        public void verify(Open request, IQ response) {
            assertEquals(StanzaType.MESSAGE, request.getStanza());
        }

    });

    try {
        // start In-Band Bytestream
        byteStreamManager.establishSession(targetJID);
    }
    catch (XMPPException e) {
        protocol.verifyAll();
    }

}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:23,代码来源:InBandBytestreamManagerTest.java

示例3: shouldReturnValidIQStanzaXML

import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType; //导入依赖的package包/类
@Test
public void shouldReturnValidIQStanzaXML() throws Exception {
    String control = XMLBuilder.create("iq")
        .a("from", "[email protected]/orchard")
        .a("to", "[email protected]/balcony")
        .a("id", "jn3h8g65")
        .a("type", "set")
        .e("open")
            .a("xmlns", "http://jabber.org/protocol/ibb")
            .a("block-size", "4096")
            .a("sid", "i781hf64")
            .a("stanza", "iq")
        .asString(outputProperties);

    Open open = new Open("i781hf64", 4096, StanzaType.IQ);
    open.setFrom("[email protected]/orchard");
    open.setTo("[email protected]/balcony");
    open.setStanzaId("jn3h8g65");
    
    assertXMLEqual(control, open.toXML().toString());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:22,代码来源:OpenTest.java

示例4: Open

import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType; //导入依赖的package包/类
/**
 * Creates a new In-Band Bytestream open request packet.
 * <p>
 * The data sent over this In-Band Bytestream will be fragmented in blocks
 * with the given block size. The block size should not be greater than
 * 65535. A recommended default value is 4096.
 * <p>
 * The data can be sent using IQ stanzas or message stanzas.
 * 
 * @param sessionID unique session ID identifying this In-Band Bytestream
 * @param blockSize block size in which the data will be fragmented
 * @param stanza stanza type used to encapsulate the data
 */
public Open(String sessionID, int blockSize, StanzaType stanza) {
    super(ELEMENT, NAMESPACE);
    if (sessionID == null || "".equals(sessionID)) {
        throw new IllegalArgumentException("Session ID must not be null or empty");
    }
    if (blockSize <= 0) {
        throw new IllegalArgumentException("Block size must be greater than zero");
    }

    this.sessionID = sessionID;
    this.blockSize = blockSize;
    this.stanza = stanza;
    setType(Type.set);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:28,代码来源:Open.java

示例5: shouldCorrectlyParseIQStanzaAttribute

import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType; //导入依赖的package包/类
@Test
public void shouldCorrectlyParseIQStanzaAttribute() throws Exception {
    String control = XMLBuilder.create("open")
        .a("xmlns", "http://jabber.org/protocol/ibb")
        .a("block-size", "4096")
        .a("sid", "i781hf64")
        .a("stanza", "iq")
        .asString(outputProperties);
    
    OpenIQProvider oip = new OpenIQProvider();
    Open open = oip.parse(getParser(control));
    
    assertEquals(StanzaType.IQ, open.getStanza());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:15,代码来源:OpenIQProviderTest.java

示例6: shouldCorrectlyParseMessageStanzaAttribute

import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType; //导入依赖的package包/类
@Test
public void shouldCorrectlyParseMessageStanzaAttribute() throws Exception {
    String control = XMLBuilder.create("open")
        .a("xmlns", "http://jabber.org/protocol/ibb")
        .a("block-size", "4096")
        .a("sid", "i781hf64")
        .a("stanza", "message")
        .asString(outputProperties);
    
    OpenIQProvider oip = new OpenIQProvider();
    Open open = oip.parse(getParser(control));
    
    assertEquals(StanzaType.MESSAGE, open.getStanza());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:15,代码来源:OpenIQProviderTest.java

示例7: setup

import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType; //导入依赖的package包/类
/**
 * Initialize fields used in the tests.
 * @throws XMPPException 
 * @throws SmackException 
 */
@Before
public void setup() throws XMPPException, SmackException {

    // build protocol verifier
    protocol = new Protocol();

    // create mocked XMPP connection
    connection = ConnectionUtils.createMockedConnection(protocol, initiatorJID, xmppServer);

    // initialize InBandBytestreamManager to get the InitiationListener
    byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);

    // create a In-Band Bytestream open packet with message stanza
    initBytestream = new Open(sessionID, blockSize, StanzaType.MESSAGE);
    initBytestream.setFrom(initiatorJID);
    initBytestream.setTo(targetJID);

    incrementingSequence = new Verification<Message, IQ>() {

        long lastSeq = 0;

        public void verify(Message request, IQ response) {
            DataPacketExtension dpe = (DataPacketExtension) request.getExtension(
                            DataPacketExtension.ELEMENT, DataPacketExtension.NAMESPACE);
            assertEquals(lastSeq++, dpe.getSeq());
        }

    };

}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:36,代码来源:InBandBytestreamSessionMessageTest.java

示例8: shouldSetAllFieldsCorrectly

import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType; //导入依赖的package包/类
@Test
public void shouldSetAllFieldsCorrectly() {
    Open open = new Open("sessionID", 4096, StanzaType.MESSAGE);
    assertEquals("sessionID", open.getSessionID());
    assertEquals(4096, open.getBlockSize());
    assertEquals(StanzaType.MESSAGE, open.getStanza());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:8,代码来源:OpenTest.java

示例9: parseIQ

import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType; //导入依赖的package包/类
public IQ parseIQ(XmlPullParser parser) throws Exception {
    String sessionID = parser.getAttributeValue("", "sid");
    int blockSize = Integer.parseInt(parser.getAttributeValue("", "block-size"));

    String stanzaValue = parser.getAttributeValue("", "stanza");
    StanzaType stanza = null;
    if (stanzaValue == null) {
        stanza = StanzaType.IQ;
    }
    else {
        stanza = StanzaType.valueOf(stanzaValue.toUpperCase());
    }

    return new Open(sessionID, blockSize, stanza);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:16,代码来源:OpenIQProvider.java

示例10: Open

import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType; //导入依赖的package包/类
/**
 * Creates a new In-Band Bytestream open request packet.
 * <p>
 * The data sent over this In-Band Bytestream will be fragmented in blocks
 * with the given block size. The block size should not be greater than
 * 65535. A recommended default value is 4096.
 * <p>
 * The data can be sent using IQ stanzas or message stanzas.
 * 
 * @param sessionID unique session ID identifying this In-Band Bytestream
 * @param blockSize block size in which the data will be fragmented
 * @param stanza stanza type used to encapsulate the data
 */
public Open(String sessionID, int blockSize, StanzaType stanza) {
    if (sessionID == null || "".equals(sessionID)) {
        throw new IllegalArgumentException("Session ID must not be null or empty");
    }
    if (blockSize <= 0) {
        throw new IllegalArgumentException("Block size must be greater than zero");
    }

    this.sessionID = sessionID;
    this.blockSize = blockSize;
    this.stanza = stanza;
    setType(Type.SET);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:27,代码来源:Open.java

示例11: parseIQ

import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType; //导入依赖的package包/类
public IQ parseIQ(XmlPullParser parser) throws Exception {
	String sessionID = parser.getAttributeValue("", "sid");
	int blockSize = Integer.parseInt(parser.getAttributeValue("",
			"block-size"));

	String stanzaValue = parser.getAttributeValue("", "stanza");
	StanzaType stanza = null;
	if (stanzaValue == null) {
		stanza = StanzaType.IQ;
	} else {
		stanza = StanzaType.valueOf(stanzaValue.toUpperCase());
	}

	return new Open(sessionID, blockSize, stanza);
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:16,代码来源:OpenIQProvider.java

示例12: testInBandBytestreamWithMessageStanzas

import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType; //导入依赖的package包/类
/**
 * An In-Band Bytestream should be successfully established using message stanzas.
 * 
 * @throws Exception should not happen
 */
public void testInBandBytestreamWithMessageStanzas() throws Exception {

    XMPPConnection initiatorConnection = getConnection(0);
    XMPPConnection targetConnection = getConnection(1);

    // test data
    Random rand = new Random();
    final byte[] data = new byte[dataSize];
    rand.nextBytes(data);
    final SynchronousQueue<byte[]> queue = new SynchronousQueue<byte[]>();

    InBandBytestreamManager targetByteStreamManager = InBandBytestreamManager.getByteStreamManager(targetConnection);

    InBandBytestreamListener incomingByteStreamListener = new InBandBytestreamListener() {

        public void incomingBytestreamRequest(InBandBytestreamRequest request) {
            InputStream inputStream;
            try {
                inputStream = request.accept().getInputStream();
                byte[] receivedData = new byte[dataSize];
                int totalRead = 0;
                while (totalRead < dataSize) {
                    int read = inputStream.read(receivedData, totalRead, dataSize - totalRead);
                    totalRead += read;
                }
                queue.put(receivedData);
            }
            catch (Exception e) {
                fail(e.getMessage());
            }
        }

    };
    targetByteStreamManager.addIncomingBytestreamListener(incomingByteStreamListener);

    InBandBytestreamManager initiatorByteStreamManager = InBandBytestreamManager.getByteStreamManager(initiatorConnection);
    initiatorByteStreamManager.setStanza(StanzaType.MESSAGE);

    OutputStream outputStream = initiatorByteStreamManager.establishSession(
                    targetConnection.getUser()).getOutputStream();

    // verify stream
    outputStream.write(data);
    outputStream.flush();
    outputStream.close();

    assertEquals("received data not equal to sent data", data, queue.take());

}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:55,代码来源:InBandBytestreamTest.java

示例13: shouldSetIQStanzaAsDefault

import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType; //导入依赖的package包/类
@Test
public void shouldSetIQStanzaAsDefault() {
    Open open = new Open("sessionID", 4096);
    assertEquals(StanzaType.IQ, open.getStanza());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:6,代码来源:OpenTest.java

示例14: shouldUseMessageStanzaIfGiven

import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType; //导入依赖的package包/类
@Test
public void shouldUseMessageStanzaIfGiven() {
    Open open = new Open("sessionID", 4096, StanzaType.MESSAGE);
    assertEquals(StanzaType.MESSAGE, open.getStanza());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:6,代码来源:OpenTest.java

示例15: Open

import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType; //导入依赖的package包/类
/**
 * Creates a new In-Band Bytestream open request packet.
 * <p>
 * The data sent over this In-Band Bytestream will be fragmented in blocks
 * with the given block size. The block size should not be greater than
 * 65535. A recommended default value is 4096.
 * <p>
 * The data can be sent using IQ stanzas or message stanzas.
 * 
 * @param sessionID
 *            unique session ID identifying this In-Band Bytestream
 * @param blockSize
 *            block size in which the data will be fragmented
 * @param stanza
 *            stanza type used to encapsulate the data
 */
public Open(String sessionID, int blockSize, StanzaType stanza) {
	if (sessionID == null || "".equals(sessionID)) {
		throw new IllegalArgumentException(
				"Session ID must not be null or empty");
	}
	if (blockSize <= 0) {
		throw new IllegalArgumentException(
				"Block size must be greater than zero");
	}

	this.sessionID = sessionID;
	this.blockSize = blockSize;
	this.stanza = stanza;
	setType(Type.SET);
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:32,代码来源:Open.java


注:本文中的org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager.StanzaType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。