- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试使用 XMPP 的消息事件接口(interface)。据我了解,您可以使用“请求送达通知”标志标记您发送的消息,然后收件人负责向您发送此通知。有没有人成功实现这个?有人可以给我一些示例代码吗?我的代码不起作用。我的监听器(MessageEventNotificationListener、MessageEventRequestListener)的回调从未被调用:
@Override
public void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
setContentView( R.layout.chat );
PacketFilter filter = new MessageTypeFilter(Message.Type.chat);
VajasKifli.connection.addPacketListener( this, filter );
tv = ( TextView ) findViewById( R.id.textView1 );
tvState = ( TextView ) findViewById( R.id.textView2 );
et = ( EditText ) findViewById( R.id.editText1 );
et.addTextChangedListener( this );
mem = new MessageEventManager( VajasKifli.connection );
mem.addMessageEventNotificationListener( this );
mem.addMessageEventRequestListener( this );
sdm = new ServiceDiscoveryManager( VajasKifli.connection );
VajasKifli.log( "sdm: " + sdm );
stateManager = ChatStateManager.getInstance( VajasKifli.connection );
recipient = getIntent().getStringExtra( "recipient" );
chat = VajasKifli.connection.getChatManager().createChat( recipient, "chat-" + recipient, this );
VajasKifli.log( "chat created: " + chat );
VajasKifli.connection.getChatManager().addChatListener( this );
sv = ( ScrollView ) findViewById( R.id.scrollView1 );
handler = new ChatHandler();
}
public void onClickSend( View view )
{
String text = et.getText().toString();
if( text.length() > 0 )
{
VajasKifli.log( "sending text [" + text + "] to [" + recipient + "]" );
try
{
Message message = new Message();
message.setBody( text );
MessageEventManager.addNotificationsRequests( message, false, true, false, false );
chat.sendMessage( message );
stateManager.setCurrentState( ChatState.active, chat );
lastState = ChatState.active;
tv.append( "\n" + VajasKifli.connection.getUser().replaceFirst( "@.*", "" ) + ": " + text );
sv.fullScroll( ScrollView.FOCUS_DOWN );
}
catch( XMPPException e )
{
VajasKifli.logError( e.toString() );
}
//showToast( "sent: " + text );
}
}
最佳答案
您应该通过 wireshark 或通过 smack 调试选项获得 XMPP 连接的数据包跟踪,以确保传送通知确实是由连接的另一端发送的。如果不是,这将解释为什么不调用监听器。
SMACK 中的消息事件是通过现已过时的 XEP-22 完成的.很有可能对方没有实现这种过时的机制。
关于Android Smack MessageEventListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7241444/
我使用 Smack API 编写我的 Google talk Client 。现在我需要处理这个添加请求。 我将 SubscriptionMode 设置为手动,现在我必须为存在数据包注册一个监听器,但
我正在尝试从应用程序服务器(TOMCAT)创建多用户聊天组,我已经在servlet中创建了一个XMPP机器人。 根据我的要求,我必须从应用程序服务器创建一个多用户聊天组(在应用程序服务器上使用 xmp
我正在将我的 android 应用程序从 asmack-android 库移动到 Smack 4.1.4。我在 Smack 的 asmack 版本中有一些 PacketExtensions,它使用 P
我正在使用 Smack API 开发多用户游戏客户端。我的 smack 应用程序遇到问题:我可以向服务器发送消息和请求,但我的应用程序无法从中读取响应。 Exception in thread "Sm
经过数小时的调试并试图找出为什么使用 aSmack 无法进行文件传输,而正常的消息传递却可以,我终于设法将其归结为这一点。 当我按照 Smack 文档中给出的方法获取用户的名册列表时,Openfire
我是 gcm 新手,我尝试使用 Smack API 连接到 GCM 的云连接服务器(XMPP)。一开始还好我的代码: uid = "123456789"; apiKey = "A***********
相关问题: Initialization exception "NoClassDefFoundError: javax.naming.directory.InitialDirContext" when
如何订阅以收听 SMACK 中的用户可用性状态变化? 要获取用户的可用性状态,我使用以下命令: XMPPConnection.getRoster().getPresence(name).isAvail
我知道之前有人问过这个问题,但 mschonaker here 只给出了部分答复.在我的网站上,用户可以将人添加到他们的花名册中,然后好友必须接受并最终连接。第一人称(用户a)使用著名的 roster
我正在为 openfire 聊天客户端创建一个 java fx 应用程序。我正在使用 smack 4.1 rc1 连接到服务器。我能够连接到服务器,向其他人发送存在信息,并向其他用户发送消息。但是我无
我正在为 openfire 聊天客户端创建一个 java fx 应用程序。我正在使用 smack 4.1 rc1 连接到服务器。我能够连接到服务器,向其他人发送存在信息,并向其他用户发送消息。但是我无
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
我正在邀请离线用户加入群组,如下所示, myChattingRoom.invite("user7@10.10.1.105", "请加入我的聊天室"); 由于邀请消息默认没有正文,因此 openfire
我一直在努力通过 Smack 和 Openfire 服务器与 XMPP 聊天。 我的问题如下: 每当一个用户向另一个用户发送消息时,该消息就会被另一个用户正确接收。但是第一条消息的发件人不会显示任何回
我在 Java 的 Smack 消息传递库中建立适当的聊天时遇到问题。如果聊天是在本地开始的,它工作得很好,但如果聊天是从另一个客户端开始的,那么会创建两个不同的聊天线程,而不仅仅是需要的那个。我发送
我正在使用下面的代码向任何用户发送好友请求,它工作正常,但我无法从花名册列表中找到已连接的用户。 现在我想知道如何在花名册列表中识别新请求的 friend 。 Roster roster = XMPP
我正在使用 smack 和 openfire 在 android 中创建聊天应用程序。对于消息状态,我在其他地方发送和显示的消息没有问题客户(仔细检查)。我将向发件人发送一条简单的 json 消息,如
嗨, friend 们,我正在使用从以下网址下载的 Smack3.2.1.jar http://www.igniterealtime.org/downloads/index.jsp 我在我的构建路径中
我正在尝试为 asmack 数据包编写一个监听器。最终发生的事情是监听器有时只是没有获取数据包并对其进行处理。以下是部分代码: try { XMPPMethods.getCon
我有以下代码来监听聊天室的邀请: Connection.DEBUG_ENABLED = true; XMPPConnection connection = new XMPPConnec
我是一名优秀的程序员,十分优秀!