本文整理汇总了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());
}
示例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);
}
示例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);
}
示例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;
}
示例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());
}
示例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;
}
示例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());
}
};
}
示例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());
}
};
}
示例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;
}