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


Java Open.setTo方法代码示例

本文整理汇总了Java中org.jivesoftware.smackx.bytestreams.ibb.packet.Open.setTo方法的典型用法代码示例。如果您正苦于以下问题:Java Open.setTo方法的具体用法?Java Open.setTo怎么用?Java Open.setTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jivesoftware.smackx.bytestreams.ibb.packet.Open的用法示例。


在下文中一共展示了Open.setTo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRespondWithErrorOnInBandBytestreamRequest

import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; //导入方法依赖的package包/类
/**
 * Target should respond with not-acceptable error if no listeners for incoming In-Band
 * Bytestream requests are registered.
 * 
 * @throws XMPPException should not happen
 */
public void testRespondWithErrorOnInBandBytestreamRequest() throws XMPPException {
    XMPPConnection targetConnection = getConnection(0);

    XMPPConnection initiatorConnection = getConnection(1);

    Open open = new Open("sessionID", 1024);
    open.setFrom(initiatorConnection.getUser());
    open.setTo(targetConnection.getUser());

    PacketCollector collector = initiatorConnection.createPacketCollector(new PacketIDFilter(
                    open.getStanzaId()));
    initiatorConnection.sendStanza(open);
    Packet result = collector.nextResult();

    assertNotNull(result.getError());
    assertEquals(XMPPError.Condition.no_acceptable.toString(), result.getError().getCondition());

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

示例2: setup

import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; //导入方法依赖的package包/类
/**
 * Initialize fields used in the tests.
 */
@Before
public void setup() {

    // mock connection
    connection = mock(XMPPConnection.class);

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

    // get the InitiationListener from InBandByteStreamManager
    initiationListener = Whitebox.getInternalState(byteStreamManager, InitiationListener.class);

    // create a In-Band Bytestream open packet
    initBytestream = new Open(sessionID, 4096);
    initBytestream.setFrom(initiatorJID);
    initBytestream.setTo(targetJID);

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

示例3: setup

import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; //导入方法依赖的package包/类
/**
 * Initialize fields used in the tests.
 */
@Before
public void setup() {

    // mock connection
    connection = mock(XMPPConnection.class);

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

    // create a In-Band Bytestream open packet
    initBytestream = new Open(sessionID, 4096);
    initBytestream.setFrom(initiatorJID);
    initBytestream.setTo(targetJID);

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

示例4: establishSession

import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; //导入方法依赖的package包/类
/**
 * Establishes an In-Band Bytestream with the given user using the given
 * session ID and returns the session to send/receive data to/from the user.
 * 
 * @param targetJID
 *            the JID of the user an In-Band Bytestream should be
 *            established
 * @param sessionID
 *            the session ID for the In-Band Bytestream request
 * @return the session to send/receive data to/from the user
 * @throws XMPPException
 *             if the user doesn't support or accept in-band bytestreams, or
 *             if the user prefers smaller block sizes
 */
public InBandBytestreamSession establishSession(String targetJID,
		String sessionID) throws XMPPException {
	Open byteStreamRequest = new Open(sessionID, this.defaultBlockSize,
			this.stanza);
	byteStreamRequest.setTo(targetJID);

	// sending packet will throw exception on timeout or error reply
	SyncPacketSend.getReply(this.connection, byteStreamRequest);

	InBandBytestreamSession inBandBytestreamSession = new InBandBytestreamSession(
			this.connection, byteStreamRequest, targetJID);
	this.sessions.put(sessionID, inBandBytestreamSession);

	return inBandBytestreamSession;
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:30,代码来源:InBandBytestreamManager.java

示例5: testRespondWithErrorOnInBandBytestreamRequest

import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; //导入方法依赖的package包/类
/**
 * Target should respond with not-acceptable error if no listeners for incoming In-Band
 * Bytestream requests are registered.
 * 
 * @throws XMPPException should not happen
 */
public void testRespondWithErrorOnInBandBytestreamRequest() throws XMPPException {
    Connection targetConnection = getConnection(0);

    Connection initiatorConnection = getConnection(1);

    Open open = new Open("sessionID", 1024);
    open.setFrom(initiatorConnection.getUser());
    open.setTo(targetConnection.getUser());

    PacketCollector collector = initiatorConnection.createPacketCollector(new PacketIDFilter(
                    open.getPacketID()));
    initiatorConnection.sendPacket(open);
    Packet result = collector.nextResult();

    assertNotNull(result.getError());
    assertEquals(XMPPError.Condition.no_acceptable.toString(), result.getError().getCondition());

}
 
开发者ID:bejayoharen,项目名称:java-bells,代码行数:25,代码来源:InBandBytestreamTest.java

示例6: establishSession

import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; //导入方法依赖的package包/类
/**
 * Establishes an In-Band Bytestream with the given user using the given session ID and returns
 * the session to send/receive data to/from the user.
 * 
 * @param targetJID the JID of the user an In-Band Bytestream should be established
 * @param sessionID the session ID for the In-Band Bytestream request
 * @return the session to send/receive data to/from the user
 * @throws XMPPErrorException if the user doesn't support or accept in-band bytestreams, or if the
 *         user prefers smaller block sizes
 * @throws NoResponseException if there was no response from the server.
 * @throws NotConnectedException 
 */
public InBandBytestreamSession establishSession(String targetJID, String sessionID)
                throws NoResponseException, XMPPErrorException, NotConnectedException {
    Open byteStreamRequest = new Open(sessionID, this.defaultBlockSize, this.stanza);
    byteStreamRequest.setTo(targetJID);

    // sending packet will throw exception on timeout or error reply
    connection.createPacketCollectorAndSend(byteStreamRequest).nextResultOrThrow();

    InBandBytestreamSession inBandBytestreamSession = new InBandBytestreamSession(
                    this.connection, byteStreamRequest, targetJID);
    this.sessions.put(sessionID, inBandBytestreamSession);

    return inBandBytestreamSession;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:27,代码来源:InBandBytestreamManager.java

示例7: setup

import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; //导入方法依赖的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: setup

import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; //导入方法依赖的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
    initBytestream = new Open(sessionID, blockSize);
    initBytestream.setFrom(initiatorJID);
    initBytestream.setTo(targetJID);

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

        long lastSeq = 0;

        public void verify(Data request, IQ response) {
            assertEquals(lastSeq++, request.getDataPacketExtension().getSeq());
        }

    };

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

示例9: establishSession

import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; //导入方法依赖的package包/类
/**
 * Establishes an In-Band Bytestream with the given user using the given session ID and returns
 * the session to send/receive data to/from the user.
 * 
 * @param targetJID the JID of the user an In-Band Bytestream should be established
 * @param sessionID the session ID for the In-Band Bytestream request
 * @return the session to send/receive data to/from the user
 * @throws XMPPException if the user doesn't support or accept in-band bytestreams, or if the
 *         user prefers smaller block sizes
 */
public InBandBytestreamSession establishSession(String targetJID, String sessionID)
                throws XMPPException {
    Open byteStreamRequest = new Open(sessionID, this.defaultBlockSize, this.stanza);
    byteStreamRequest.setTo(targetJID);

    // sending packet will throw exception on timeout or error reply
    SyncPacketSend.getReply(this.connection, byteStreamRequest);

    InBandBytestreamSession inBandBytestreamSession = new InBandBytestreamSession(
                    this.connection, byteStreamRequest, targetJID);
    this.sessions.put(sessionID, inBandBytestreamSession);

    return inBandBytestreamSession;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:25,代码来源:InBandBytestreamManager.java


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