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

Java Bytestream类代码示例

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

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



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

示例1: negotiateIncomingStream

import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; //导入依赖的package包/类
@Override
InputStream negotiateIncomingStream(Stanza streamInitiation) throws InterruptedException,
                SmackException, XMPPErrorException {
    // build SOCKS5 Bytestream request
    Socks5BytestreamRequest request = new ByteStreamRequest(this.manager,
                    (Bytestream) streamInitiation);

    // always accept the request
    Socks5BytestreamSession session = request.accept();

    // test input stream
    try {
        PushbackInputStream stream = new PushbackInputStream(session.getInputStream());
        int firstByte = stream.read();
        stream.unread(firstByte);
        return stream;
    }
    catch (IOException e) {
        throw new SmackException("Error establishing input stream", e);
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:22,代码来源:Socks5TransferNegotiator.java


示例2: setServiceEnabled

import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; //导入依赖的package包/类
/**
 * Enable the Jabber services related to file transfer on the particular
 * connection.
 *
 * @param connection The connection on which to enable or disable the services.
 * @param isEnabled  True to enable, false to disable.
 */
private static void setServiceEnabled(final XMPPConnection connection,
        final boolean isEnabled) {
    ServiceDiscoveryManager manager = ServiceDiscoveryManager
            .getInstanceFor(connection);

    List<String> namespaces = new ArrayList<String>();
    namespaces.addAll(Arrays.asList(NAMESPACE));
    namespaces.add(DataPacketExtension.NAMESPACE);
    if (!IBB_ONLY) {
        namespaces.add(Bytestream.NAMESPACE);
    }

    for (String namespace : namespaces) {
        if (isEnabled) {
            manager.addFeature(namespace);
        } else {
            manager.removeFeature(namespace);
        }
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:28,代码来源:FileTransferNegotiator.java


示例3: isServiceEnabled

import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; //导入依赖的package包/类
/**
 * Checks to see if all file transfer related services are enabled on the
 * connection.
 *
 * @param connection The connection to check
 * @return True if all related services are enabled, false if they are not.
 */
public static boolean isServiceEnabled(final XMPPConnection connection) {
    ServiceDiscoveryManager manager = ServiceDiscoveryManager
            .getInstanceFor(connection);

    List<String> namespaces = new ArrayList<String>();
    namespaces.addAll(Arrays.asList(NAMESPACE));
    namespaces.add(DataPacketExtension.NAMESPACE);
    if (!IBB_ONLY) {
        namespaces.add(Bytestream.NAMESPACE);
    }

    for (String namespace : namespaces) {
        if (!manager.includesFeature(namespace)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:26,代码来源:FileTransferNegotiator.java


示例4: testRespondWithErrorOnSocks5BytestreamRequest

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

    XMPPConnection initiatorConnection = getConnection(1);

    Bytestream bytestreamInitiation = Socks5PacketUtils.createBytestreamInitiation(
                    initiatorConnection.getUser(), targetConnection.getUser(), "session_id");
    bytestreamInitiation.addStreamHost("proxy.localhost", "127.0.0.1", 7777);

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

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

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


示例5: determineStreamHostInfos

import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; //导入依赖的package包/类
/**
 * Returns a list of stream hosts containing the IP address an the port for the given list of
 * SOCKS5 proxy JIDs. The order of the returned list is the same as the given list of JIDs
 * excluding all SOCKS5 proxies who's network settings could not be determined. If a local
 * SOCKS5 proxy is running it will be the first item in the list returned.
 * 
 * @param proxies a list of SOCKS5 proxy JIDs
 * @return a list of stream hosts containing the IP address an the port
 */
private List<StreamHost> determineStreamHostInfos(List<String> proxies) {
    List<StreamHost> streamHosts = new ArrayList<StreamHost>();

    // add local proxy on first position if exists
    List<StreamHost> localProxies = getLocalStreamHost();
    if (localProxies != null) {
        streamHosts.addAll(localProxies);
    }

    // query SOCKS5 proxies for network settings
    for (String proxy : proxies) {
        Bytestream streamHostRequest = createStreamHostRequest(proxy);
        try {
            Bytestream response = (Bytestream) SyncPacketSend.getReply(this.connection,
                            streamHostRequest);
            streamHosts.addAll(response.getStreamHosts());
        }
        catch (XMPPException e) {
            // blacklist errornous proxies
            this.proxyBlacklist.add(proxy);
        }
    }

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


示例6: negotiateIncomingStream

import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; //导入依赖的package包/类
@Override
InputStream negotiateIncomingStream(Packet streamInitiation) throws XMPPException,
                InterruptedException {
    // build SOCKS5 Bytestream request
    Socks5BytestreamRequest request = new ByteStreamRequest(this.manager,
                    (Bytestream) streamInitiation);

    // always accept the request
    Socks5BytestreamSession session = request.accept();

    // test input stream
    try {
        PushbackInputStream stream = new PushbackInputStream(session.getInputStream());
        int firstByte = stream.read();
        stream.unread(firstByte);
        return stream;
    }
    catch (IOException e) {
        throw new XMPPException("Error establishing input stream", e);
    }
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:22,代码来源:Socks5TransferNegotiator.java


示例7: determineStreamHostInfos

import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; //导入依赖的package包/类
/**
 * Returns a list of stream hosts containing the IP address an the port for
 * the given list of SOCKS5 proxy JIDs. The order of the returned list is
 * the same as the given list of JIDs excluding all SOCKS5 proxies who's
 * network settings could not be determined. If a local SOCKS5 proxy is
 * running it will be the first item in the list returned.
 * 
 * @param proxies
 *            a list of SOCKS5 proxy JIDs
 * @return a list of stream hosts containing the IP address an the port
 */
private List<StreamHost> determineStreamHostInfos(List<String> proxies) {
	List<StreamHost> streamHosts = new ArrayList<StreamHost>();

	// add local proxy on first position if exists
	List<StreamHost> localProxies = getLocalStreamHost();
	if (localProxies != null) {
		streamHosts.addAll(localProxies);
	}

	// query SOCKS5 proxies for network settings
	for (String proxy : proxies) {
		Bytestream streamHostRequest = createStreamHostRequest(proxy);
		try {
			Bytestream response = (Bytestream) SyncPacketSend.getReply(
					this.connection, streamHostRequest);
			streamHosts.addAll(response.getStreamHosts());
		} catch (XMPPException e) {
			// blacklist errornous proxies
			this.proxyBlacklist.add(proxy);
		}
	}

	return streamHosts;
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:36,代码来源:Socks5BytestreamManager.java


示例8: negotiateIncomingStream

import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; //导入依赖的package包/类
@Override
InputStream negotiateIncomingStream(Packet streamInitiation)
		throws XMPPException, InterruptedException {
	// build SOCKS5 Bytestream request
	Socks5BytestreamRequest request = new ByteStreamRequest(this.manager,
			(Bytestream) streamInitiation);

	// always accept the request
	Socks5BytestreamSession session = request.accept();

	// test input stream
	try {
		PushbackInputStream stream = new PushbackInputStream(
				session.getInputStream());
		int firstByte = stream.read();
		stream.unread(firstByte);
		return stream;
	} catch (IOException e) {
		throw new XMPPException("Error establishing input stream", e);
	}
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:22,代码来源:Socks5TransferNegotiator.java


示例9: testRespondWithErrorOnSocks5BytestreamRequest

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

    Connection initiatorConnection = getConnection(1);

    Bytestream bytestreamInitiation = Socks5PacketUtils.createBytestreamInitiation(
                    initiatorConnection.getUser(), targetConnection.getUser(), "session_id");
    bytestreamInitiation.addStreamHost("proxy.localhost", "127.0.0.1", 7777);

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

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

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


示例10: processRequest

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

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

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

    // build bytestream request from packet
    Socks5BytestreamRequest request = new Socks5BytestreamRequest(this.manager,
                    byteStreamRequest);

    // notify listeners for bytestream initiation from a specific user
    BytestreamListener userListener = this.manager.getUserListener(byteStreamRequest.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(byteStreamRequest);
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:37,代码来源:InitiationListener.java


示例11: createUsedHostResponse

import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; //导入依赖的package包/类
/**
 * Returns the response to the SOCKS5 Bytestream request containing the SOCKS5 proxy used.
 * 
 * @param selectedHost the used SOCKS5 proxy
 * @return the response to the SOCKS5 Bytestream request
 */
private Bytestream createUsedHostResponse(StreamHost selectedHost) {
    Bytestream response = new Bytestream(this.bytestreamRequest.getSessionID());
    response.setTo(this.bytestreamRequest.getFrom());
    response.setType(IQ.Type.result);
    response.setStanzaId(this.bytestreamRequest.getStanzaId());
    response.setUsedHost(selectedHost.getJID());
    return response;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:15,代码来源:Socks5BytestreamRequest.java


示例12: createStreamHostActivation

import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; //导入依赖的package包/类
/**
 * Returns a SOCKS5 Bytestream activation packet.
 * 
 * @return SOCKS5 Bytestream activation packet
 */
private Bytestream createStreamHostActivation() {
    Bytestream activate = new Bytestream(this.sessionID);
    activate.setMode(null);
    activate.setType(IQ.Type.set);
    activate.setTo(this.streamHost.getJID());

    activate.setToActivate(this.target);

    return activate;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:16,代码来源:Socks5ClientForInitiator.java


示例13: disableService

import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; //导入依赖的package包/类
/**
 * Disables the SOCKS5 Bytestream manager by removing the SOCKS5 Bytestream feature from the
 * service discovery, disabling the listener for SOCKS5 Bytestream initiation requests and
 * resetting its internal state, which includes removing this instance from the managers map.
 * <p>
 * To re-enable the SOCKS5 Bytestream feature invoke {@link #getBytestreamManager(XMPPConnection)}.
 * Using the file transfer API will automatically re-enable the SOCKS5 Bytestream feature.
 */
public synchronized void disableService() {
    XMPPConnection connection = connection();
    // remove initiation packet listener
    connection.unregisterIQRequestHandler(initiationListener);

    // shutdown threads
    this.initiationListener.shutdown();

    // clear listeners
    this.allRequestListeners.clear();
    this.userListeners.clear();

    // reset internal state
    this.lastWorkingProxy = null;
    this.proxyBlacklist.clear();
    this.ignoredBytestreamRequests.clear();

    // remove manager from static managers map
    managers.remove(connection);

    // shutdown local SOCKS5 proxy if there are no more managers for other connections
    if (managers.size() == 0) {
        Socks5Proxy.getSocks5Proxy().stop();
    }

    // remove feature from service discovery
    ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);

    // check if service discovery is not already disposed by connection shutdown
    if (serviceDiscoveryManager != null) {
        serviceDiscoveryManager.removeFeature(Bytestream.NAMESPACE);
    }

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


示例14: determineStreamHostInfos

import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; //导入依赖的package包/类
/**
 * Returns a list of stream hosts containing the IP address an the port for the given list of
 * SOCKS5 proxy JIDs. The order of the returned list is the same as the given list of JIDs
 * excluding all SOCKS5 proxies who's network settings could not be determined. If a local
 * SOCKS5 proxy is running it will be the first item in the list returned.
 * 
 * @param proxies a list of SOCKS5 proxy JIDs
 * @return a list of stream hosts containing the IP address an the port
 */
private List<StreamHost> determineStreamHostInfos(List<String> proxies) {
    XMPPConnection connection = connection();
    List<StreamHost> streamHosts = new ArrayList<StreamHost>();

    // add local proxy on first position if exists
    List<StreamHost> localProxies = getLocalStreamHost();
    if (localProxies != null) {
        streamHosts.addAll(localProxies);
    }

    // query SOCKS5 proxies for network settings
    for (String proxy : proxies) {
        Bytestream streamHostRequest = createStreamHostRequest(proxy);
        try {
            Bytestream response = (Bytestream) connection.createPacketCollectorAndSend(
                            streamHostRequest).nextResultOrThrow();
            streamHosts.addAll(response.getStreamHosts());
        }
        catch (Exception e) {
            // blacklist errornous proxies
            this.proxyBlacklist.add(proxy);
        }
    }

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


示例15: createStreamHostRequest

import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; //导入依赖的package包/类
/**
 * Returns a IQ stanza(/packet) to query a SOCKS5 proxy its network settings.
 * 
 * @param proxy the proxy to query
 * @return IQ stanza(/packet) to query a SOCKS5 proxy its network settings
 */
private Bytestream createStreamHostRequest(String proxy) {
    Bytestream request = new Bytestream();
    request.setType(IQ.Type.get);
    request.setTo(proxy);
    return request;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:13,代码来源:Socks5BytestreamManager.java


示例16: createBytestreamInitiation

import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; //导入依赖的package包/类
/**
 * Returns a SOCKS5 Bytestream initialization request stanza(/packet) with the given session ID
 * containing the given stream hosts for the given target JID.
 * 
 * @param sessionID the session ID for the SOCKS5 Bytestream
 * @param targetJID the target JID of SOCKS5 Bytestream request
 * @param streamHosts a list of SOCKS5 proxies the target should connect to
 * @return a SOCKS5 Bytestream initialization request packet
 */
private Bytestream createBytestreamInitiation(String sessionID, String targetJID,
                List<StreamHost> streamHosts) {
    Bytestream initiation = new Bytestream(sessionID);

    // add all stream hosts
    for (StreamHost streamHost : streamHosts) {
        initiation.addStreamHost(streamHost);
    }

    initiation.setType(IQ.Type.set);
    initiation.setTo(targetJID);

    return initiation;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:24,代码来源:Socks5BytestreamManager.java


示例17: getSupportedProtocols

import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; //导入依赖的package包/类
/**
 * Returns a collection of the supported transfer protocols.
 *
 * @return Returns a collection of the supported transfer protocols.
 */
public static Collection<String> getSupportedProtocols() {
    List<String> protocols = new ArrayList<String>();
    protocols.add(DataPacketExtension.NAMESPACE);
    if (!IBB_ONLY) {
        protocols.add(Bytestream.NAMESPACE);
    }
    return Collections.unmodifiableList(protocols);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:14,代码来源:FileTransferNegotiator.java


示例18: getNegotiator

import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; //导入依赖的package包/类
private StreamNegotiator getNegotiator(final FormField field)
        throws NoAcceptableTransferMechanisms {
    String variable;
    boolean isByteStream = false;
    boolean isIBB = false;
    for (FormField.Option option : field.getOptions()) {
        variable = option.getValue();
        if (variable.equals(Bytestream.NAMESPACE) && !IBB_ONLY) {
            isByteStream = true;
        }
        else if (variable.equals(DataPacketExtension.NAMESPACE)) {
            isIBB = true;
        }
    }

    if (!isByteStream && !isIBB) {
        throw new FileTransferException.NoAcceptableTransferMechanisms();
    }

    if (isByteStream && isIBB) { 
        return new FaultTolerantNegotiator(connection(),
                byteStreamTransferManager,
                inbandTransferManager);
    }
    else if (isByteStream) {
        return byteStreamTransferManager;
    }
    else {
        return inbandTransferManager;
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:32,代码来源:FileTransferNegotiator.java


示例19: getOutgoingNegotiator

import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; //导入依赖的package包/类
private StreamNegotiator getOutgoingNegotiator(final FormField field) throws NoAcceptableTransferMechanisms {
    boolean isByteStream = false;
    boolean isIBB = false;
    for (String variable : field.getValues()) {
        if (variable.equals(Bytestream.NAMESPACE) && !IBB_ONLY) {
            isByteStream = true;
        }
        else if (variable.equals(DataPacketExtension.NAMESPACE)) {
            isIBB = true;
        }
    }

    if (!isByteStream && !isIBB) {
        throw new FileTransferException.NoAcceptableTransferMechanisms();
    }

    if (isByteStream && isIBB) {
        return new FaultTolerantNegotiator(connection(),
                byteStreamTransferManager, inbandTransferManager);
    }
    else if (isByteStream) {
        return byteStreamTransferManager;
    }
    else {
        return inbandTransferManager;
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:28,代码来源:FileTransferNegotiator.java


示例20: createDefaultInitiationForm

import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream; //导入依赖的package包/类
private DataForm createDefaultInitiationForm() {
    DataForm form = new DataForm(DataForm.Type.form);
    FormField field = new FormField(STREAM_DATA_FIELD_NAME);
    field.setType(FormField.Type.list_single);
    if (!IBB_ONLY) {
        field.addOption(new FormField.Option(Bytestream.NAMESPACE));
    }
    field.addOption(new FormField.Option(DataPacketExtension.NAMESPACE));
    form.addField(field);
    return form;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:12,代码来源:FileTransferNegotiator.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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