开发者

how to start a conversation with bonjour client knowing its name@host:port?

开发者 https://www.devze.com 2023-04-12 16:17 出处:网络
I am working on a project of P2P instant messenger, like ichat, but just for LAN. I use jmdns library for service discovering, and test with pidgin and log in as a Bonjour user. as so far,the service

I am working on a project of P2P instant messenger, like ichat, but just for LAN.

I use jmdns library for service discovering, and test with pidgin and log in as a Bonjour user. as so far,the service _presence._tcp.local. is well discovered,

then we know the user's information in LAN like name@host:port, so how t开发者_如何学运维o start a conversation with Bonjour client ?

I looked into XMPP, but it do not support P2P, but I can hardly find the library for the extension jingle which supports P2P.

maybe I should use SIP to make a conversation? but the packet format is compatible with Bonjour ? or I have to study the structure of packet exchanged?

Can anyone explain a little about how does ichat work for LAN?

Many thanks for your kind help!


I think you're a little confused.

Bonjour is a mechanism for finding a service. It is not for communicating with a service. Once you have found the name@host:port information, you are finished with Bonjour.

The next step will require you to talk a protocol that the service understands. The token _presence in the service string indicates that this is an XMPP service. You will need to talk XMPP to it. You cannot talk SIP to it. Have you tried opening an XMPP connection to the host and port you have found?

You talk about SIP and Jingle. These are used to set up an audio or video call. If you are writing an instant messaging program, you do not need to do this. XMPP alone is enough.

If you do want to support audio or video, then you will need one of those protocols. Because the service you have found is an XMPP service, you will need to use Jingle. If you don't have a library that can speak Jingle, you will have to write the code yourself. There is nothing in the Bonjour information that identifies a SIP service, so you cannot use SIP - unless you can make a different Bonjour query and find a SIP service.

I infer that you are working in Java. The most popular XMPP library for Java seems to be Smack.


Thanks for everybody's attention, now I have found something. XMPP doesn't support P2P mode, only supports clients-server-clients. but there is another standard "XEP-0174: Serverless Messaging" which is right for p2p chat in local network. DNS-SD + XEP-0174 , ichat works in this way.
as I used smack library, it do not support p2P; but someone did some changes, here is the link http://issues.igniterealtime.org/browse/SMACK-262 .
I didn't try this XMPPLLConnection, I have looked into the source code of smack, it is based on socket connection. unfortunately there is not any java library for XEP-1074, so I have to work on xml stream over socket.


You may use SIP for that. MDNS will be your discovery mechanism, then you'd use plain SIP for calling, one you learned the URI you wish to dial.

SIPSIMPLE SDK (http://sipsimpleclient.com) implements this feature by sing this expired draft: https://datatracker.ietf.org/doc/html/draft-lee-sip-dns-sd-uri-03 it could be a good start.

Basically your client would generate a URI like sip:random_stuff@ip:port and then publish it along with a display name by using MDNS. The application also browses MDNS for peers on the LAN: _sipuri._udp for example. Once you get some URI you can just dial using SIP.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号