本文介绍了STOMP或XMPP-通过websocket的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事一个涉及实时聊天(消息传递,包括群聊)的项目.

I am working on a project which involves real time chat (messaging, including group chats).

我以前使用过websockets,所以我开始使用spring-websockets进行这项工作,并且我读了一些有关实现它的最佳方法的文章.然后我遇到了STOMP(作为Websocket的子协议),并且由于在春天对STOMP有了直接支持,因此实现我应该做的事情有点容易.

I have worked with websockets before, So I started working on this using spring-websockets and I did some reading about what is the best way to implement it. Then I came across STOMP (as a sub-protocol for websockets)and as there is direct support for STOMP in spring it was bit easy to achieve what I was supposed to do.

但是我的怀疑是,据我所知STOMP和XMPP是相似的协议(消息协议),但是我找不到任何解释了差异的问题/博客,以及为什么有人会比其他人更喜欢?

But my doubt is as far as my understanding STOMP and XMPP are similar protocols(messaging protocols) but I could not find any questions/blogs where the differences are explained and why somebody would prefer one over another?

如果有人解释这两个协议有何不同,那将真的很有帮助?

It will be really helpful if somebody explains how these two protocols differ?

谢谢.

推荐答案

作为Jabber的继任者,XMPP更加专注于即时消息传递而不是STOMP. XMPP是可扩展协议,可以用于其他目的,但是有很多关于IM的内置机制和实现. STOMP提供了更通用的机制,此处的消息"指的是广泛的含义.

As the successor of Jabber, XMPP is more focused on instant messaging instead of STOMP. XMPP is an extensible protocol and could be used for other purposes, but there are plenty of built-in mechanism and implementations regarding IM. STOMP offers a more general mechanism and "message" here refers a broad meaning.

假设您为项目选择STOMP.然后,您可能需要为XMPP已经提供的某些方案(点对点,群聊)定义基本消息.

Let's say you choose STOMP for your project. Then you will probably need to define basic messages for certain scenarios (peer-to-peer, group chat) which are already offered by XMPP.

比较两种协议;

  • STOMP消息以纯文本形式(如其名称所示)携带,而XMPP则被构造为XML.
  • 可以通过TCP或WebSockets建立
  • STOMP连接. XMPP支持TCP或HTTP(也是推荐的).
  • 在Java世界中, Spring 可以通话STOMP,非常容易实现.但是,可以通过添加第三方API(即 Smack )
  • 来添加XMPP支持.
  • STOMP message is carried as plain text (as its name indicates) whereas XMPP is structured as XML.
  • STOMP connections can be established via TCP or WebSockets. XMPP supports TCP or HTTP (WebSocket standard is also propopsed).
  • In Java world, Spring has the ability to talk STOMP and it's very easy to implement. However, XMPP support can be added by adding 3rd Party APIs (i.e. Smack)

这篇关于STOMP或XMPP-通过websocket的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-09 13:42