本文整理汇总了Java中org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager类的典型用法代码示例。如果您正苦于以下问题:Java Socks5BytestreamManager类的具体用法?Java Socks5BytestreamManager怎么用?Java Socks5BytestreamManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Socks5BytestreamManager类属于org.jivesoftware.smackx.bytestreams.socks5包,在下文中一共展示了Socks5BytestreamManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendFile
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager; //导入依赖的package包/类
/**
* Send file to provided JID via a SOCKS5 Bytestream session (XEP-0065).
*
* @param file
* @param jid
* @throws SmackException
* @throws InterruptedException
* @throws IOException
* @throws XMPPException
*/
public void sendFile(byte[] file, String jid)
throws XMPPException, IOException, InterruptedException, SmackException {
String jidFinal = getFullJid(jid);
jidFinal += "/receiver";
Socks5BytestreamManager bytestreamManager = Socks5BytestreamManager.getBytestreamManager(connection);
OutputStream outputStream = null;
try {
Socks5BytestreamSession session = bytestreamManager.establishSession(jidFinal);
outputStream = session.getOutputStream();
outputStream.write(file);
outputStream.flush();
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
}
}
}
示例2: setServiceEnabled
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager; //导入依赖的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.
*/
public static void setServiceEnabled(final Connection connection,
final boolean isEnabled) {
ServiceDiscoveryManager manager = ServiceDiscoveryManager
.getInstanceFor(connection);
List<String> namespaces = new ArrayList<String>();
namespaces.addAll(Arrays.asList(NAMESPACE));
namespaces.add(InBandBytestreamManager.NAMESPACE);
if (!IBB_ONLY) {
namespaces.add(Socks5BytestreamManager.NAMESPACE);
}
for (String namespace : namespaces) {
if (isEnabled) {
if (!manager.includesFeature(namespace)) {
manager.addFeature(namespace);
}
} else {
manager.removeFeature(namespace);
}
}
}
示例3: isServiceEnabled
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager; //导入依赖的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 Connection connection) {
ServiceDiscoveryManager manager = ServiceDiscoveryManager
.getInstanceFor(connection);
List<String> namespaces = new ArrayList<String>();
namespaces.addAll(Arrays.asList(NAMESPACE));
namespaces.add(InBandBytestreamManager.NAMESPACE);
if (!IBB_ONLY) {
namespaces.add(Socks5BytestreamManager.NAMESPACE);
}
for (String namespace : namespaces) {
if (!manager.includesFeature(namespace)) {
return false;
}
}
return true;
}
示例4: setServiceEnabled
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager; //导入依赖的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.
*/
public static void setServiceEnabled(final Connection connection,
final boolean isEnabled) {
ServiceDiscoveryManager manager = ServiceDiscoveryManager
.getInstanceFor(connection);
List<String> namespaces = new ArrayList<String>();
namespaces.addAll(Arrays.asList(NAMESPACE));
namespaces.add(InBandBytestreamManager.NAMESPACE);
if (!IBB_ONLY) {
namespaces.add(Socks5BytestreamManager.NAMESPACE);
}
for (String namespace : namespaces) {
if (isEnabled) {
if (!manager.includesFeature(namespace)) {
manager.addFeature(namespace);
}
} else {
manager.removeFeature(namespace);
}
}
}
示例5: isServiceEnabled
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager; //导入依赖的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 Connection connection) {
ServiceDiscoveryManager manager = ServiceDiscoveryManager
.getInstanceFor(connection);
List<String> namespaces = new ArrayList<String>();
namespaces.addAll(Arrays.asList(NAMESPACE));
namespaces.add(InBandBytestreamManager.NAMESPACE);
if (!IBB_ONLY) {
namespaces.add(Socks5BytestreamManager.NAMESPACE);
}
for (String namespace : namespaces) {
if (!manager.includesFeature(namespace)) {
return false;
}
}
return true;
}
示例6: testInitializationSocks5FeaturesAndListenerOnStartup
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager; //导入依赖的package包/类
/**
* Socks5 feature should be added to the service discovery on Smack startup.
*
* @throws XMPPException should not happen
*/
public void testInitializationSocks5FeaturesAndListenerOnStartup() throws XMPPException {
XMPPConnection connection = getConnection(0);
assertTrue(ServiceDiscoveryManager.getInstanceFor(connection).includesFeature(
Socks5BytestreamManager.NAMESPACE));
}
示例7: getSupportedProtocols
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager; //导入依赖的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(InBandBytestreamManager.NAMESPACE);
if (!IBB_ONLY) {
protocols.add(Socks5BytestreamManager.NAMESPACE);
}
return Collections.unmodifiableList(protocols);
}
示例8: getNegotiator
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager; //导入依赖的package包/类
private StreamNegotiator getNegotiator(final FormField field)
throws XMPPException {
String variable;
boolean isByteStream = false;
boolean isIBB = false;
for (Iterator<FormField.Option> it = field.getOptions(); it.hasNext();) {
variable = it.next().getValue();
if (variable.equals(Socks5BytestreamManager.NAMESPACE) && !IBB_ONLY) {
isByteStream = true;
}
else if (variable.equals(InBandBytestreamManager.NAMESPACE)) {
isIBB = true;
}
}
if (!isByteStream && !isIBB) {
XMPPError error = new XMPPError(XMPPError.Condition.bad_request,
"No acceptable transfer mechanism");
throw new XMPPException(error.getMessage(), error);
}
if (isByteStream && isIBB && field.getType().equals(FormField.TYPE_LIST_MULTI)) {
return new FaultTolerantNegotiator(connection,
byteStreamTransferManager,
inbandTransferManager);
}
else if (isByteStream) {
return byteStreamTransferManager;
}
else {
return inbandTransferManager;
}
}
示例9: getOutgoingNegotiator
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager; //导入依赖的package包/类
private StreamNegotiator getOutgoingNegotiator(final FormField field)
throws XMPPException {
String variable;
boolean isByteStream = false;
boolean isIBB = false;
for (Iterator<String> it = field.getValues(); it.hasNext();) {
variable = it.next();
if (variable.equals(Socks5BytestreamManager.NAMESPACE) && !IBB_ONLY) {
isByteStream = true;
}
else if (variable.equals(InBandBytestreamManager.NAMESPACE)) {
isIBB = true;
}
}
if (!isByteStream && !isIBB) {
XMPPError error = new XMPPError(XMPPError.Condition.bad_request,
"No acceptable transfer mechanism");
throw new XMPPException(error.getMessage(), error);
}
if (isByteStream && isIBB) {
return new FaultTolerantNegotiator(connection,
byteStreamTransferManager, inbandTransferManager);
}
else if (isByteStream) {
return byteStreamTransferManager;
}
else {
return inbandTransferManager;
}
}
示例10: createDefaultInitiationForm
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager; //导入依赖的package包/类
private DataForm createDefaultInitiationForm() {
DataForm form = new DataForm(Form.TYPE_FORM);
FormField field = new FormField(STREAM_DATA_FIELD_NAME);
field.setType(FormField.TYPE_LIST_MULTI);
if (!IBB_ONLY) {
field.addOption(new FormField.Option(Socks5BytestreamManager.NAMESPACE));
}
field.addOption(new FormField.Option(InBandBytestreamManager.NAMESPACE));
form.addField(field);
return form;
}
示例11: getNegotiator
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager; //导入依赖的package包/类
private StreamNegotiator getNegotiator(final FormField field)
throws XMPPException {
String variable;
boolean isByteStream = false;
boolean isIBB = false;
for (Iterator<FormField.Option> it = field.getOptions(); it.hasNext();) {
variable = it.next().getValue();
if (variable.equals(Socks5BytestreamManager.NAMESPACE) && !IBB_ONLY) {
isByteStream = true;
}
else if (variable.equals(InBandBytestreamManager.NAMESPACE)) {
isIBB = true;
}
}
if (!isByteStream && !isIBB) {
XMPPError error = new XMPPError(XMPPError.Condition.bad_request,
"No acceptable transfer mechanism");
throw new XMPPException(error.getMessage(), error);
}
//if (isByteStream && isIBB && field.getType().equals(FormField.TYPE_LIST_MULTI)) {
if (isByteStream && isIBB) {
return new FaultTolerantNegotiator(connection,
byteStreamTransferManager,
inbandTransferManager);
}
else if (isByteStream) {
return byteStreamTransferManager;
}
else {
return inbandTransferManager;
}
}
示例12: createDefaultInitiationForm
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager; //导入依赖的package包/类
private DataForm createDefaultInitiationForm() {
DataForm form = new DataForm(Form.TYPE_FORM);
FormField field = new FormField(STREAM_DATA_FIELD_NAME);
field.setType(FormField.TYPE_LIST_SINGLE);
if (!IBB_ONLY) {
field.addOption(new FormField.Option(Socks5BytestreamManager.NAMESPACE));
}
field.addOption(new FormField.Option(InBandBytestreamManager.NAMESPACE));
form.addField(field);
return form;
}
示例13: getSupportedProtocols
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager; //导入依赖的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(InBandBytestreamManager.NAMESPACE);
if (!IBB_ONLY) {
protocols.add(Socks5BytestreamManager.NAMESPACE);
}
return Collections.unmodifiableList(protocols);
}
示例14: getNegotiator
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager; //导入依赖的package包/类
private StreamNegotiator getNegotiator(final FormField field)
throws XMPPException {
String variable;
boolean isByteStream = false;
boolean isIBB = false;
for (Iterator<FormField.Option> it = field.getOptions(); it.hasNext();) {
variable = it.next().getValue();
if (variable.equals(Socks5BytestreamManager.NAMESPACE) && !IBB_ONLY) {
isByteStream = true;
} else if (variable.equals(InBandBytestreamManager.NAMESPACE)) {
isIBB = true;
}
}
if (!isByteStream && !isIBB) {
XMPPError error = new XMPPError(XMPPError.Condition.bad_request,
"No acceptable transfer mechanism");
throw new XMPPException(error.getMessage(), error);
}
// if (isByteStream && isIBB &&
// field.getType().equals(FormField.TYPE_LIST_MULTI)) {
if (isByteStream && isIBB) {
return new FaultTolerantNegotiator(connection,
byteStreamTransferManager, inbandTransferManager);
} else if (isByteStream) {
return byteStreamTransferManager;
} else {
return inbandTransferManager;
}
}
示例15: getOutgoingNegotiator
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager; //导入依赖的package包/类
private StreamNegotiator getOutgoingNegotiator(final FormField field)
throws XMPPException {
String variable;
boolean isByteStream = false;
boolean isIBB = false;
for (Iterator<String> it = field.getValues(); it.hasNext();) {
variable = it.next();
if (variable.equals(Socks5BytestreamManager.NAMESPACE) && !IBB_ONLY) {
isByteStream = true;
} else if (variable.equals(InBandBytestreamManager.NAMESPACE)) {
isIBB = true;
}
}
if (!isByteStream && !isIBB) {
XMPPError error = new XMPPError(XMPPError.Condition.bad_request,
"No acceptable transfer mechanism");
throw new XMPPException(error.getMessage(), error);
}
if (isByteStream || isIBB) {
return new FaultTolerantNegotiator(connection,
byteStreamTransferManager, inbandTransferManager);
} else if (isByteStream) {
return byteStreamTransferManager;
} else {
return inbandTransferManager;
}
}