- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我无法收到服务器发送的这个 IQ 数据包。
如何在 XMPPFramework 中监听自定义 IQ 数据包?
此方法无效:
- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq
我正在使用 XMPPFramework .
<iq id="pvrequest" type="get">
<pvcommand xmlns='detayopenfireplugin:iq:customiq'>
<sendClassName>MainScreenController</sendClassName>
<sendMethodName>getMainUsersInfo</sendMethodName>
<spvcommand>eyJtbmFtZSI6ImdldE1haW5Vc2Vyc0luZm9Gb3JXZWIiLCJjbGlkIjoiMTAwIiwiY25hbWUiOiJvcmcuZGV0YXlzb2Z0LmF0b21pYy5kZXRheW9wZW5maXJlcGx1Z2luLnByb2Nlc3Nvci5leHRlcm5hbHByb2Nlc3Nvci5zdWJwcm9jZXNzb3IuQnVzaW5lc3MiLCJ1c2lkIjoiUDA0MDUifQ==</spvcommand>
</pvcommand>
</iq>
最佳答案
您是否在 View Controller 中为 xmpp 分配了委托(delegate)。
(void)setupStream
{
NSAssert(xmppStream == nil, @"Method setupStream invoked multiple times");
// Setup xmpp stream
//
// The XMPPStream is the base class for all activity.
// Everything else plugs into the xmppStream, such as modules/extensions and delegates.
xmppStream = [[XMPPStream alloc] init];
#if !TARGET_IPHONE_SIMULATOR
{
// Want xmpp to run in the background?
//
// P.S. - The simulator doesn't support backgrounding yet.
// When you try to set the associated property on the simulator, it simply fails.
// And when you background an app on the simulator,
// it just queues network traffic til the app is foregrounded again.
// We are patiently waiting for a fix from Apple.
// If you do enableBackgroundingOnSocket on the simulator,
// you will simply see an error message from the xmpp stack when it fails to set the property.
xmppStream.enableBackgroundingOnSocket = YES;
}
#endif
// Setup reconnect
//
// The XMPPReconnect module monitors for "accidental disconnections" and
// automatically reconnects the stream for you.
// There's a bunch more information in the XMPPReconnect header file.
xmppReconnect = [[XMPPReconnect alloc] init];
// Setup roster
//
// The XMPPRoster handles the xmpp protocol stuff related to the roster.
// The storage for the roster is abstracted.
// So you can use any storage mechanism you want.
// You can store it all in memory, or use core data and store it on disk, or use core data with an in-memory store,
// or setup your own using raw SQLite, or create your own storage mechanism.
// You can do it however you like! It's your application.
// But you do need to provide the roster with some storage facility.
xmppRosterStorage = [[XMPPRosterCoreDataStorage alloc] init];
// xmppRosterStorage = [[XMPPRosterCoreDataStorage alloc] initWithInMemoryStore];
xmppRoster = [[XMPPRoster alloc] initWithRosterStorage:xmppRosterStorage];
xmppRoster.autoFetchRoster = YES;
xmppRoster.autoAcceptKnownPresenceSubscriptionRequests = YES;
// Setup vCard support
//
// The vCard Avatar module works in conjuction with the standard vCard Temp module to download user avatars.
// The XMPPRoster will automatically integrate with XMPPvCardAvatarModule to cache roster photos in the roster.
xmppvCardStorage = [XMPPvCardCoreDataStorage sharedInstance];
xmppvCardTempModule = [[XMPPvCardTempModule alloc] initWithvCardStorage:xmppvCardStorage];
xmppvCardAvatarModule = [[XMPPvCardAvatarModule alloc] initWithvCardTempModule:xmppvCardTempModule];
// Setup capabilities
//
// The XMPPCapabilities module handles all the complex hashing of the caps protocol (XEP-0115).
// Basically, when other clients broadcast their presence on the network
// they include information about what capabilities their client supports (audio, video, file transfer, etc).
// But as you can imagine, this list starts to get pretty big.
// This is where the hashing stuff comes into play.
// Most people running the same version of the same client are going to have the same list of capabilities.
// So the protocol defines a standardized way to hash the list of capabilities.
// Clients then broadcast the tiny hash instead of the big list.
// The XMPPCapabilities protocol automatically handles figuring out what these hashes mean,
// and also persistently storing the hashes so lookups aren't needed in the future.
//
// Similarly to the roster, the storage of the module is abstracted.
// You are strongly encouraged to persist caps information across sessions.
//
// The XMPPCapabilitiesCoreDataStorage is an ideal solution.
// It can also be shared amongst multiple streams to further reduce hash lookups.
xmppCapabilitiesStorage = [XMPPCapabilitiesCoreDataStorage sharedInstance];
xmppCapabilities = [[XMPPCapabilities alloc] initWithCapabilitiesStorage:xmppCapabilitiesStorage];
xmppCapabilities.autoFetchHashedCapabilities = YES;
xmppCapabilities.autoFetchNonHashedCapabilities = NO;
// Activate xmpp modules
[xmppReconnect activate:xmppStream];
[xmppRoster activate:xmppStream];
[xmppvCardTempModule activate:xmppStream];
[xmppvCardAvatarModule activate:xmppStream];
[xmppCapabilities activate:xmppStream];
// Add ourself as a delegate to anything we may be interested in
[xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppRoster addDelegate:self delegateQueue:dispatch_get_main_queue()];
// Optional:
//
// Replace me with the proper domain and port.
// The example below is setup for a typical google talk account.
//
// If you don't supply a hostName, then it will be automatically resolved using the JID (below).
// For example, if you supply a JID like 'user@quack.com/rsrc'
// then the xmpp framework will follow the xmpp specification, and do a SRV lookup for quack.com.
//
// If you don't specify a hostPort, then the default (5222) will be used.
// [xmppStream setHostName:@"talk.google.com"];
// [xmppStream setHostPort:5222];
// You may need to alter these settings depending on the server you're connecting to
allowSelfSignedCertificates = NO;
allowSSLHostNameMismatch = NO;
}
关于ios - XMPPFramework - 如何收听自定义 IQ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24531545/
我有监听 unix 套接字的进程。但是,在我阅读之前,我想检查一些有关此传入消息的元数据,例如它的源进程(比如我想删除来自不受信任的发件人的消息)。是否有任何系统调用可以检索此信息。 if(l
我目前正在开发一个使用 Spring AMQP 和 RabbitMQ 的 Java 应用程序,我想监控我的队列并在某些事件发生时得到通知,比如 元素已添加到队列中, 元素被移除,或者 元素再次进入队列
我正在使用如下定义的 spring jms 监听器。它通常工作正常,但我看到它根据 recieveTimeout 设置不断断开连接和重新连接。
我如何在 Java 中监听原始打印机端口 9100。 当我在端口 9100 上创建 ServerSocket 并接受连接时,当我尝试打印到此端口时,没有任何反应。 System.out.println
问题在标题中,但要详细说明一下。如果我使用 Sun/Oracle NIO API 或类似 Netty 的框架在 Java 中编写 NIO 应用程序,是否可以让客户端作为订阅者“连接”,即使没有服务器绑
我需要收听来自 UDP 的网络广播。数据报包含一个 j4cDAC_broadcast 结构。我尝试按照一些教程进行操作,但它们似乎遗漏了一些内容并且没有非常详细的解释(如果有的话)。 我现在得到的是错
我目前正在通过带有参数的拨号协议(protocol)启动 Amazon FireTV 应用程序。可以通过这样的 Intent 在 onCreate() 中访问此参数: Intent intent =
我想听游标的任何变化。是否可以在不使用 android 中的 contentprovider 的情况下实现这一目标? 注意:(我没有使用任何数据适配器) 谢谢 最佳答案 我发现你不需要使用内容提供者。
我想在 Linux 上使用 C 中的 Libpcap 编写一个小型应用程序。 目前,它开始嗅探并等待数据包。但这并不是我真正需要的。我希望它等待 N 秒然后停止收听。 我怎样才能做到这一点? 这是我的
如何在用户关闭 Modal Bottom Sheet 时执行一段代码? showModalBottomSheet( context: context, buil
我如何在 B 类中监听来自 A 类的 PropertyChanged 事件?我想听听 A 类的属性变化。 class A : INotifyPropertyChanged { priv
当新 Activity 开始或android中的任何任务时,有没有办法通过广播或任何其他方式接收事件? 谢谢马哈茂德 最佳答案 您想做什么,一些分析或日志记录或其他什么? 好吧,如果您要监控的是您自己
我在 SWT 事件方面遇到了困难。 有没有办法在 Combo 关闭时收到通知?我需要知道它何时关闭并且选择没有更改。 我注意到有一个事件类型 SWT.Collapse,但据我所知,这只适用于 Tree
我有一个套接字,我正在尝试从客户端向服务器发送信息。两者位于同一网络,具有不同的 LAN IP(如下所示): 我的服务器是我的 C# 应用程序。 - 192.168.0.2我的客户端是我的 Andro
我是 Gstreamer 的新手,我想用它来收听 RTP 流。 为此,我使用此管道: gst-launch-1.0 udpsrc caps=application/x-rtp port=5000 !
我有一个包含大量所有级别日志记录的应用程序。我希望向 Log.Fatal 调用添加一些自定义行为。如果不构建自定义 Appender 是否可以做到这一点? 我试过这个: log4net.Uti
我有我的 android 应用程序,它监听浏览器 Intent ,以便在用户单击某种类型的 URI 时捕获它们。更具体地说,我希望我的应用程序在用户单击指向 torrent 文件的超链接(例如 htt
我想做的是以下内容:一个服务,持续监听 gps(是的:JUST gps)位置更新而不主动请求它们 - 即这个应用程序不应该消耗额外的资源电池生命周期或 CPU 时间,直到其他应用程序请求/接收 GPS
我有一个 Bootstrap 5 accordion看起来像这样: Bar ... 我正
我是 tweepy 的新手。并尝试实现一个 API,它可以监听新推文中的@提及或屏幕名称。 tweets = api.user_timeline(screen_name=username) 但它没有收
我是一名优秀的程序员,十分优秀!