• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Open类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: parse

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

import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param connection the XMPP connection
 * @param byteStreamRequest the In-Band Bytestream open request for this session
 * @param remoteJID JID of the remote peer
 */
protected InBandBytestreamSession(XMPPConnection connection, Open byteStreamRequest,
                String remoteJID) {
    this.connection = connection;
    this.byteStreamRequest = byteStreamRequest;
    this.remoteJID = remoteJID;

    // initialize streams dependent to the uses stanza type
    switch (byteStreamRequest.getStanza()) {
    case IQ:
        this.inputStream = new IQIBBInputStream();
        this.outputStream = new IQIBBOutputStream();
        break;
    case MESSAGE:
        this.inputStream = new MessageIBBInputStream();
        this.outputStream = new MessageIBBOutputStream();
        break;
    }

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


示例3: 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


示例4: 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


示例5: shouldUseConfiguredStanzaType

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


示例6: 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


示例7: InBandBytestreamSession

import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param connection the XMPP connection
 * @param byteStreamRequest the In-Band Bytestream open request for this session
 * @param remoteJID JID of the remote peer
 */
protected InBandBytestreamSession(Connection connection, Open byteStreamRequest,
                String remoteJID) {
    this.connection = connection;
    this.byteStreamRequest = byteStreamRequest;
    this.remoteJID = remoteJID;

    // initialize streams dependent to the uses stanza type
    switch (byteStreamRequest.getStanza()) {
    case IQ:
        this.inputStream = new IQIBBInputStream();
        this.outputStream = new IQIBBOutputStream();
        break;
    case MESSAGE:
        this.inputStream = new MessageIBBInputStream();
        this.outputStream = new MessageIBBOutputStream();
        break;
    }

}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:27,代码来源:InBandBytestreamSession.java


示例8: 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


示例9: InBandBytestreamSession

import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param connection
 *            the XMPP connection
 * @param byteStreamRequest
 *            the In-Band Bytestream open request for this session
 * @param remoteJID
 *            JID of the remote peer
 */
protected InBandBytestreamSession(Connection connection,
		Open byteStreamRequest, String remoteJID) {
	this.connection = connection;
	this.byteStreamRequest = byteStreamRequest;
	this.remoteJID = remoteJID;

	// initialize streams dependent to the uses stanza type
	switch (byteStreamRequest.getStanza()) {
	case IQ:
		this.inputStream = new IQIBBInputStream();
		this.outputStream = new IQIBBOutputStream();
		break;
	case MESSAGE:
		this.inputStream = new MessageIBBInputStream();
		this.outputStream = new MessageIBBOutputStream();
		break;
	}

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


示例10: 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


示例11: processRequest

import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; //导入依赖的package包/类
private void processRequest(Stanza packet) throws NotConnectedException {
    Open ibbRequest = (Open) packet;

    // validate that block size is within allowed range
    if (ibbRequest.getBlockSize() > this.manager.getMaximumBlockSize()) {
        this.manager.replyResourceConstraintPacket(ibbRequest);
        return;
    }

    StreamNegotiator.signal(ibbRequest.getFrom() + '\t' + ibbRequest.getSessionID(), ibbRequest);

    // ignore request if in ignore list
    if (this.manager.getIgnoredBytestreamRequests().remove(ibbRequest.getSessionID()))
        return;

    // build bytestream request from packet
    InBandBytestreamRequest request = new InBandBytestreamRequest(this.manager, ibbRequest);

    // notify listeners for bytestream initiation from a specific user
    BytestreamListener userListener = this.manager.getUserListener(ibbRequest.getFrom());
    if (userListener != null) {
        userListener.incomingBytestreamRequest(request);

    }
    else if (!this.manager.getAllRequestListeners().isEmpty()) {
        /*
         * if there is no user specific listener inform listeners for all initiation requests
         */
        for (BytestreamListener listener : this.manager.getAllRequestListeners()) {
            listener.incomingBytestreamRequest(request);
        }

    }
    else {
        /*
         * if there is no listener for this initiation request, reply with reject message
         */
        this.manager.replyRejectPacket(ibbRequest);
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:41,代码来源:InitiationListener.java


示例12: 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


示例13: determineNegotiator

import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; //导入依赖的package包/类
private StreamNegotiator determineNegotiator(Stanza streamInitiation) {
    if (streamInitiation instanceof Bytestream) {
        return primaryNegotiator;
    } else if (streamInitiation instanceof Open){
        return secondaryNegotiator;
    } else {
        throw new IllegalStateException("Unknown stream initation type");
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:10,代码来源:FaultTolerantNegotiator.java


示例14: negotiateIncomingStream

import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; //导入依赖的package包/类
InputStream negotiateIncomingStream(Stanza streamInitiation) throws NotConnectedException {
    // build In-Band Bytestream request
    InBandBytestreamRequest request = new ByteStreamRequest(this.manager,
                    (Open) streamInitiation);

    // always accept the request
    InBandBytestreamSession session = request.accept();
    session.setCloseBothStreamsEnabled(true);
    return session.getInputStream();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:11,代码来源:IBBTransferNegotiator.java


示例15: shouldCorrectlyParseIQStanzaAttribute

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


示例16: shouldCorrectlyParseMessageStanzaAttribute

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


示例17: 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


示例18: 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


示例19: processRequest

import org.jivesoftware.smackx.bytestreams.ibb.packet.Open; //导入依赖的package包/类
private void processRequest(Packet packet) {
    Open ibbRequest = (Open) packet;

    // validate that block size is within allowed range
    if (ibbRequest.getBlockSize() > this.manager.getMaximumBlockSize()) {
        this.manager.replyResourceConstraintPacket(ibbRequest);
        return;
    }

    // ignore request if in ignore list
    if (this.manager.getIgnoredBytestreamRequests().remove(ibbRequest.getSessionID()))
        return;

    // build bytestream request from packet
    InBandBytestreamRequest request = new InBandBytestreamRequest(this.manager, ibbRequest);

    // notify listeners for bytestream initiation from a specific user
    BytestreamListener userListener = this.manager.getUserListener(ibbRequest.getFrom());
    if (userListener != null) {
        userListener.incomingBytestreamRequest(request);

    }
    else if (!this.manager.getAllRequestListeners().isEmpty()) {
        /*
         * if there is no user specific listener inform listeners for all initiation requests
         */
        for (BytestreamListener listener : this.manager.getAllRequestListeners()) {
            listener.incomingBytestreamRequest(request);
        }

    }
    else {
        /*
         * if there is no listener for this initiation request, reply with reject message
         */
        this.manager.replyRejectPacket(ibbRequest);
    }
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:39,代码来源:InitiationListener.java


示例20: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MavenUtil类代码示例发布时间:2022-05-23
下一篇:
Java ObjectAdapter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap