简体   繁体   English

实施SIP即时消息框架

[英]Implement SIP instant messaging framework

I want to implement an instant messaging framework working on SIP. 我想实现一个在SIP上工作的即时消息框架。 I have SIP clients and an element that will get all the messages from the clients, and will handle them and forward them to other sip clients. 我有SIP客户端和一个将从客户端获取所有消息并处理它们并将其转发给其他sip客户端的元素。

The clients and the managing element will have their own private protocol ("talking" with each other) that will be delivered inside the SIP messages (in the payload for example). 客户端和管理元素将具有自己的私有协议(彼此“交谈”),该私有协议将在SIP消息内部(例如,在有效负载中)传递。

What I don't know is what I need the "managing element" to be. 我不知道我需要什么“管理元素”。 Should it be a SIP client, or a SIP server? 它应该是SIP客户端还是SIP服务器? What I was thinking is that I will have a SIP client that will receive all the SIP messages, parse them using the private protocol, and forward it to other clients. 我当时的想法是,我将拥有一个SIP客户端,该客户端将接收所有SIP消息,使用专用协议解析它们,然后将其转发给其他客户端。 So it will be a kind of "server" in the terms on managing the system but a client in the terms of SIP. 因此,就系统管理而言,它将是一种“服务器”,而对于SIP,它将是一种客户端。

I'm implementing this "element" in Java, but it doesn't really matter now. 我正在用Java实现此“元素”,但现在实际上并不重要。 I will be happy to get some direction to help me. 我很乐意为您提供指导。

With your problem, I would start by choosing between 2 models: 对于您的问题,我将从两种模型之间进行选择开始:

1- Your IM clients establish a session (SIP dialog) with the IM server (or dispatcher or "element" or whatever it is called) and keep it alive for as long as they are running, or signed in. In this case, the SIP dialog is always established from the IM client to the IM server, so the former can be called a SIP client, and the later a SIP server. 1-您的IM客户端与IM服务器(或调度程序或“元素”或任何称为它的东西)建立会话(SIP对话框),并在它们运行或登录期间保持活动状态。在这种情况下,从IM客户端到IM服务器始终建立SIP对话框,因此前者可以称为SIP客户端,而后者可以称为SIP服务器。 IM messages are then delivered in both direction on that dialog, using mid-dialog requests. 然后,使用中间对话请求在该对话框上双向传送IM消息。 This is probably a good idea, if you know the IM server is routable from anywhere, but the clients are likely to be in private networks. 如果您知道IM服务器可从任何地方路由,但客户端很可能位于专用网络中,则这可能是一个好主意。

2- A more symmetric approach is that there is no ongoing dialog. 2-更对称的方法是没有正在进行的对话。 Whenever either entity, IM client or IM server, wants to send a message to the other, then it just uses a one-off out-of-dialog SIP message. 每当一个实体(IM客户端或IM服务器)想要向另一个实体发送消息时,它仅使用一次性的非对话SIP消息。 In this case, both ends need to implement SIP UA client and UA server functionalities. 在这种情况下,两端都需要实现SIP UA客户端和UA服务器功能。 This could be a preferred solution in any case, when maintaining dialogs between IM clients and servers seems like a bad idea, but routing is not an issue. 在任何情况下,当维护IM客户端和服务器之间的对话框似乎是一个坏主意,但路由都不是问题时,这可能是首选的解决方案。

Of course, there is a half way solution too, which looks like the second one, but instead of every message being sent on its own, out of a dialog context, a temporary dialog can be established to send messages (and avoid re-authenticating every single message for example) until some inactivity timer takes the dialog down. 当然,也有一种半途而废的解决方案,看起来像第二种解决方案,但不是在对话框上下文之外单独发送每条消息,而是可以建立一个临时对话框来发送消息(并避免重新验证)例如每条消息),直到某个不活动计时器将对话框关闭。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM