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

Java StreamInitiation类代码示例

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

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



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

示例1: createInitiationAccept

import org.jivesoftware.smackx.packet.StreamInitiation; //导入依赖的package包/类
/**
 * Creates the initiation acceptance packet to forward to the stream
 * initiator.
 *
 * @param streamInitiationOffer The offer from the stream initiator to connect for a stream.
 * @param namespaces            The namespace that relates to the accepted means of transfer.
 * @return The response to be forwarded to the initiator.
 */
public StreamInitiation createInitiationAccept(
        StreamInitiation streamInitiationOffer, String[] namespaces)
{
    StreamInitiation response = new StreamInitiation();
    response.setTo(streamInitiationOffer.getFrom());
    response.setFrom(streamInitiationOffer.getTo());
    response.setType(IQ.Type.RESULT);
    response.setPacketID(streamInitiationOffer.getPacketID());

    DataForm form = new DataForm(Form.TYPE_SUBMIT);
    FormField field = new FormField(
            FileTransferNegotiator.STREAM_DATA_FIELD_NAME);
    for (String namespace : namespaces) {
        field.addValue(namespace);
    }
    form.addField(field);

    response.setFeatureNegotiationForm(form);
    return response;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:29,代码来源:StreamNegotiator.java


示例2: initiateIncomingStream

import org.jivesoftware.smackx.packet.StreamInitiation; //导入依赖的package包/类
Packet initiateIncomingStream(Connection connection, StreamInitiation initiation) throws XMPPException {
    StreamInitiation response = createInitiationAccept(initiation,
            getNamespaces());

    // establish collector to await response
    PacketCollector collector = connection
            .createPacketCollector(getInitiationPacketFilter(initiation.getFrom(), initiation.getSessionID()));
    connection.sendPacket(response);

    Packet streamMethodInitiation = collector
            .nextResult(SmackConfiguration.getPacketReplyTimeout());
    collector.cancel();
    if (streamMethodInitiation == null) {
        throw new XMPPException("No response from file transfer initiator");
    }

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


示例3: createInitiationAccept

import org.jivesoftware.smackx.packet.StreamInitiation; //导入依赖的package包/类
/**
 * Creates the initiation acceptance packet to forward to the stream
 * initiator.
 * 
 * @param streamInitiationOffer
 *            The offer from the stream initiator to connect for a stream.
 * @param namespaces
 *            The namespace that relates to the accepted means of transfer.
 * @return The response to be forwarded to the initiator.
 */
public StreamInitiation createInitiationAccept(
		StreamInitiation streamInitiationOffer, String[] namespaces) {
	StreamInitiation response = new StreamInitiation();
	response.setTo(streamInitiationOffer.getFrom());
	response.setFrom(streamInitiationOffer.getTo());
	response.setType(IQ.Type.RESULT);
	response.setPacketID(streamInitiationOffer.getPacketID());

	DataForm form = new DataForm(Form.TYPE_SUBMIT);
	FormField field = new FormField(
			FileTransferNegotiator.STREAM_DATA_FIELD_NAME);
	for (String namespace : namespaces) {
		field.addValue(namespace);
	}
	form.addField(field);

	response.setFeatureNegotiationForm(form);
	return response;
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:30,代码来源:StreamNegotiator.java


示例4: initiateIncomingStream

import org.jivesoftware.smackx.packet.StreamInitiation; //导入依赖的package包/类
Packet initiateIncomingStream(Connection connection,
		StreamInitiation initiation) throws XMPPException {
	StreamInitiation response = createInitiationAccept(initiation,
			getNamespaces());

	// establish collector to await response
	PacketCollector collector = connection
			.createPacketCollector(getInitiationPacketFilter(
					initiation.getFrom(), initiation.getSessionID()));
	connection.sendPacket(response);

	Packet streamMethodInitiation = collector.nextResult(SmackConfiguration
			.getPacketReplyTimeout());
	collector.cancel();
	if (streamMethodInitiation == null) {
		throw new XMPPException("No response from file transfer initiator");
	}

	return streamMethodInitiation;
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:21,代码来源:StreamNegotiator.java


示例5: createInitiationAccept

import org.jivesoftware.smackx.packet.StreamInitiation; //导入依赖的package包/类
/**
 * Creates the initiation acceptance packet to forward to the stream
 * initiator.
 *
 * @param streamInitiationOffer The offer from the stream initatior to connect for a stream.
 * @param namespaces            The namespace that relates to the accepted means of transfer.
 * @return The response to be forwarded to the initator.
 */
public StreamInitiation createInitiationAccept(
        StreamInitiation streamInitiationOffer, String[] namespaces)
{
    StreamInitiation response = new StreamInitiation();
    response.setTo(streamInitiationOffer.getFrom());
    response.setFrom(streamInitiationOffer.getTo());
    response.setType(IQ.Type.RESULT);
    response.setPacketID(streamInitiationOffer.getPacketID());

    DataForm form = new DataForm(Form.TYPE_SUBMIT);
    FormField field = new FormField(
            FileTransferNegotiator.STREAM_DATA_FIELD_NAME);
    for (String namespace : namespaces) {
        field.addValue(namespace);
    }
    form.addField(field);

    response.setFeatureNegotiationForm(form);
    return response;
}
 
开发者ID:phoenixNirvana,项目名称:NewCommunication-Android,代码行数:29,代码来源:StreamNegotiator.java


示例6: initListeners

import org.jivesoftware.smackx.packet.StreamInitiation; //导入依赖的package包/类
private void initListeners() {
	listeners = new ArrayList<FileTransferListener>();

	connection.addPacketListener(new PacketListener() {
		public void processPacket(Packet packet) {
			fireNewRequest((StreamInitiation) packet);
		}
	}, new AndFilter(new PacketTypeFilter(StreamInitiation.class),
			new IQTypeFilter(IQ.Type.SET)));
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:11,代码来源:FileTransferManager.java


示例7: fireNewRequest

import org.jivesoftware.smackx.packet.StreamInitiation; //导入依赖的package包/类
protected void fireNewRequest(StreamInitiation initiation) {
	FileTransferListener[] listeners = null;
	synchronized (this.listeners) {
		listeners = new FileTransferListener[this.listeners.size()];
		this.listeners.toArray(listeners);
	}
	FileTransferRequest request = new FileTransferRequest(this, initiation);
	for (int i = 0; i < listeners.length; i++) {
		listeners[i].fileTransferRequest(request);
	}
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:12,代码来源:FileTransferManager.java


示例8: rejectIncomingFileTransfer

import org.jivesoftware.smackx.packet.StreamInitiation; //导入依赖的package包/类
protected void rejectIncomingFileTransfer(FileTransferRequest request) {
	StreamInitiation initiation = request.getStreamInitiation();

	IQ rejection = FileTransferNegotiator.createIQ(
			initiation.getPacketID(), initiation.getFrom(), initiation
					.getTo(), IQ.Type.ERROR);
	rejection.setError(new XMPPError(XMPPError.Condition.forbidden));
	connection.sendPacket(rejection);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:10,代码来源:FileTransferManager.java


示例9: createIncomingStream

import org.jivesoftware.smackx.packet.StreamInitiation; //导入依赖的package包/类
@Override
public InputStream createIncomingStream(StreamInitiation initiation) throws XMPPException,
                InterruptedException {
    /*
     * SOCKS5 initiation listener must ignore next SOCKS5 Bytestream request with given session
     * ID
     */
    this.manager.ignoreBytestreamRequestOnce(initiation.getSessionID());

    Packet streamInitiation = initiateIncomingStream(this.connection, initiation);
    return negotiateIncomingStream(streamInitiation);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:13,代码来源:Socks5TransferNegotiator.java


示例10: rejectStream

import org.jivesoftware.smackx.packet.StreamInitiation; //导入依赖的package包/类
/**
 * Reject a stream initiation request from a remote user.
 *
 * @param si The Stream Initiation request to reject.
 */
public void rejectStream(final StreamInitiation si) {
    XMPPError error = new XMPPError(XMPPError.Condition.forbidden, "Offer Declined");
    IQ iqPacket = createIQ(si.getPacketID(), si.getFrom(), si.getTo(),
            IQ.Type.ERROR);
    iqPacket.setError(error);
    connection.sendPacket(iqPacket);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:13,代码来源:FileTransferNegotiator.java


示例11: createIncomingStream

import org.jivesoftware.smackx.packet.StreamInitiation; //导入依赖的package包/类
public InputStream createIncomingStream(StreamInitiation initiation)
                throws XMPPException {
    /*
     * In-Band Bytestream initiation listener must ignore next in-band
     * bytestream request with given session ID
     */
    this.manager.ignoreBytestreamRequestOnce(initiation.getSessionID());

    Packet streamInitiation = initiateIncomingStream(this.connection, initiation);
    return negotiateIncomingStream(streamInitiation);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:12,代码来源:IBBTransferNegotiator.java


示例12: rejectIncomingFileTransfer

import org.jivesoftware.smackx.packet.StreamInitiation; //导入依赖的package包/类
protected void rejectIncomingFileTransfer(FileTransferRequest request) {
	StreamInitiation initiation = request.getStreamInitiation();

	IQ rejection = FileTransferNegotiator.createIQ(
			initiation.getPacketID(), initiation.getFrom(), initiation
					.getTo(), IQ.Type.ERROR);
	rejection.setError(new XMPPError(XMPPError.Condition.no_acceptable));
	connection.sendPacket(rejection);
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:10,代码来源:FileTransferManager.java


示例13: rejectIncomingFileTransfer

import org.jivesoftware.smackx.packet.StreamInitiation; //导入依赖的package包/类
protected void rejectIncomingFileTransfer(FileTransferRequest request) {
	StreamInitiation initiation = request.getStreamInitiation();

	IQ rejection = FileTransferNegotiator.createIQ(
			initiation.getPacketID(), initiation.getFrom(),
			initiation.getTo(), IQ.Type.ERROR);
	rejection.setError(new XMPPError(XMPPError.Condition.no_acceptable));
	connection.sendPacket(rejection);
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:10,代码来源:FileTransferManager.java


示例14: createIncomingStream

import org.jivesoftware.smackx.packet.StreamInitiation; //导入依赖的package包/类
@Override
public InputStream createIncomingStream(StreamInitiation initiation)
		throws XMPPException, InterruptedException {
	/*
	 * SOCKS5 initiation listener must ignore next SOCKS5 Bytestream request
	 * with given session ID
	 */
	this.manager.ignoreBytestreamRequestOnce(initiation.getSessionID());

	Packet streamInitiation = initiateIncomingStream(this.connection,
			initiation);
	return negotiateIncomingStream(streamInitiation);
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:14,代码来源:Socks5TransferNegotiator.java


示例15: rejectStream

import org.jivesoftware.smackx.packet.StreamInitiation; //导入依赖的package包/类
/**
 * Reject a stream initiation request from a remote user.
 * 
 * @param si
 *            The Stream Initiation request to reject.
 */
public void rejectStream(final StreamInitiation si) {
	XMPPError error = new XMPPError(XMPPError.Condition.forbidden,
			"Offer Declined");
	IQ iqPacket = createIQ(si.getPacketID(), si.getFrom(), si.getTo(),
			IQ.Type.ERROR);
	iqPacket.setError(error);
	connection.sendPacket(iqPacket);
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:15,代码来源:FileTransferNegotiator.java


示例16: negotiateOutgoingTransfer

import org.jivesoftware.smackx.packet.StreamInitiation; //导入依赖的package包/类
/**
 * Send a request to another user to send them a file. The other user has
 * the option of, accepting, rejecting, or not responding to a received file
 * transfer request.
 * <p/>
 * If they accept, the packet will contain the other user's chosen stream
 * type to send the file across. The two choices this implementation
 * provides to the other user for file transfer are <a
 * href="http://www.jabber.org/jeps/jep-0065.html">SOCKS5 Bytestreams</a>,
 * which is the preferred method of transfer, and <a
 * href="http://www.jabber.org/jeps/jep-0047.html">In-Band Bytestreams</a>,
 * which is the fallback mechanism.
 * <p/>
 * The other user may choose to decline the file request if they do not
 * desire the file, their client does not support JEP-0096, or if there are
 * no acceptable means to transfer the file.
 * <p/>
 * Finally, if the other user does not respond this method will return null
 * after the specified timeout.
 * 
 * @param userID
 *            The userID of the user to whom the file will be sent.
 * @param streamID
 *            The unique identifier for this file transfer.
 * @param fileName
 *            The name of this file. Preferably it should include an
 *            extension as it is used to determine what type of file it is.
 * @param size
 *            The size, in bytes, of the file.
 * @param desc
 *            A description of the file.
 * @param responseTimeout
 *            The amount of time, in milliseconds, to wait for the remote
 *            user to respond. If they do not respond in time, this
 * @return Returns the stream negotiator selected by the peer.
 * @throws XMPPException
 *             Thrown if there is an error negotiating the file transfer.
 */
public StreamNegotiator negotiateOutgoingTransfer(final String userID,
		final String streamID, final String fileName, final long size,
		final String desc, int responseTimeout) throws XMPPException {
	StreamInitiation si = new StreamInitiation();
	si.setSesssionID(streamID);
	si.setMimeType(URLConnection.guessContentTypeFromName(fileName));

	StreamInitiation.File siFile = new StreamInitiation.File(fileName, size);
	siFile.setDesc(desc);
	si.setFile(siFile);

	si.setFeatureNegotiationForm(createDefaultInitiationForm());

	si.setFrom(connection.getUser());
	si.setTo(userID);
	si.setType(IQ.Type.SET);

	PacketCollector collector = connection
			.createPacketCollector(new PacketIDFilter(si.getPacketID()));
	connection.sendPacket(si);
	Packet siResponse = collector.nextResult(responseTimeout);
	collector.cancel();

	if (siResponse instanceof IQ) {
		IQ iqResponse = (IQ) siResponse;
		if (iqResponse.getType().equals(IQ.Type.RESULT)) {
			StreamInitiation response = (StreamInitiation) siResponse;
			return getOutgoingNegotiator(getStreamMethodField(response
					.getFeatureNegotiationForm()));

		} else if (iqResponse.getType().equals(IQ.Type.ERROR)) {
			throw new XMPPException(iqResponse.getError());
		} else {
			throw new XMPPException("File transfer response unreadable");
		}
	} else {
		return null;
	}
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:78,代码来源:FileTransferNegotiator.java


示例17: createIncomingStream

import org.jivesoftware.smackx.packet.StreamInitiation; //导入依赖的package包/类
public InputStream createIncomingStream(StreamInitiation initiation)
		throws XMPPException {
	/*
	 * In-Band Bytestream initiation listener must ignore next in-band
	 * bytestream request with given session ID
	 */
	this.manager.ignoreBytestreamRequestOnce(initiation.getSessionID());

	Packet streamInitiation = initiateIncomingStream(this.connection,
			initiation);
	return negotiateIncomingStream(streamInitiation);
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:13,代码来源:IBBTransferNegotiator.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Users类代码示例发布时间:2022-05-23
下一篇:
Java NoSuchDirectoryException类代码示例发布时间: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