Commit 1ed742a7 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Added multicast DNS support (JM-84).


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@725 b35dd754-fafc-0310-a699-88a17e54d16e
parent b6b3829c
......@@ -231,6 +231,7 @@
<root url="jar://$PROJECT_DIR$/build/lib/merge/whack.jar!/" />
<root url="jar://$PROJECT_DIR$/build/lib/merge/jdic.jar!/" />
<root url="jar://$PROJECT_DIR$/build/lib/merge/xpp3.jar!/" />
<root url="jar://$PROJECT_DIR$/build/lib/merge/jmdns.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
......
......@@ -20,4 +20,5 @@ xmltask.jar | 1.10.5
jstl.jar | Jakarta standard taglib 1.1.2
standard.jar | Jakarta standard taglib 1.1.2
xpp3.jar | XPP_3 1.1.3.4.K
whack.jar | Dec-2-2004
\ No newline at end of file
whack.jar | Dec-2-2004
jmdns.jar | 1.0 RC1
\ No newline at end of file
......@@ -31,6 +31,7 @@ import org.jivesoftware.util.Version;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.net.MulticastDNSService;
import org.dom4j.io.SAXReader;
import org.dom4j.Document;
......@@ -253,6 +254,7 @@ public class XMPPServer {
loadModule(IQDiscoInfoHandler.class.getName());
loadModule(IQDiscoItemsHandler.class.getName());
loadModule(MultiUserChatServerImpl.class.getName());
loadModule(MulticastDNSService.class.getName());
}
/**
......
......@@ -37,7 +37,10 @@ public class XMPPServerInfoImpl implements XMPPServerInfo {
*
* @param serverName the server's serverName (e.g. example.org).
* @param version the server's version number.
* @param startDate the server's last start time (can be null indicating it hasn't been started). * @param stopDate The server's last stop time (can be null indicating it is running or hasn't been started)
* @param startDate the server's last start time (can be null indicating
* it hasn't been started).
* @param stopDate the server's last stop time (can be null indicating it
* is running or hasn't been started).
* @param portIter the portIter active on the server.
*/
public XMPPServerInfoImpl(String serverName, Version version, Date startDate, Date stopDate,
......@@ -79,4 +82,4 @@ public class XMPPServerInfoImpl implements XMPPServerInfo {
public Iterator getServerPorts() {
return ports;
}
}
}
\ No newline at end of file
/**
* $RCSfile$
* $Revision$
* $Date$
*
* Copyright (C) 2004 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.net;
import org.jivesoftware.messenger.container.BasicModule;
import org.jivesoftware.messenger.XMPPServer;
import org.jivesoftware.messenger.XMPPServerInfo;
import org.jivesoftware.messenger.ServerPort;
import org.jivesoftware.util.Log;
import org.jivesoftware.admin.AdminConsole;
import javax.jmdns.JmDNS;
import javax.jmdns.ServiceInfo;
import java.io.IOException;
import java.util.Iterator;
/**
* Publishes Jive Messenger as a service using the Multicast DNS (marketed by Apple
* as Rendezvous) protocol. This lets other nodes on the local network to discover
* the name and port of Jive Messenger.<p>
*
* The multicast DNS entry is published with a type of "_xmpp._tcp.local.".
*
* @author Matt Tucker
*/
public class MulticastDNSService extends BasicModule {
private JmDNS jmdns;
private ServiceInfo serviceInfo;
public MulticastDNSService() {
super("Multicast DNS Service");
}
public void initialize(XMPPServer server) {
try {
jmdns = new JmDNS();
}
catch (IOException ioe) {
Log.error(ioe);
}
}
public void start() throws IllegalStateException {
if (jmdns != null) {
Runnable startService = new Runnable() {
public void run() {
XMPPServerInfo info = XMPPServer.getInstance().getServerInfo();
Iterator ports = info.getServerPorts();
int portNum = -1;
while (ports.hasNext()) {
ServerPort port = (ServerPort)ports.next();
if (!port.isSecure()) {
portNum = port.getPort();
}
}
try {
if (portNum != -1) {
String serverName = AdminConsole.getAppName();
serviceInfo = new ServiceInfo("_xmpp._tcp.local.",
serverName, portNum, 0, 0, "XMPP Server");
jmdns.registerService(serviceInfo);
}
}
catch (IOException ioe) {
Log.error(ioe);
}
}
};
new Thread(startService).start();
}
}
public void stop() {
if (jmdns != null) {
try {
jmdns.unregisterService(serviceInfo);
}
catch (Exception e) { }
}
}
public void destroy() {
if (jmdns != null) {
try {
jmdns.close();
jmdns = null;
}
catch (Exception e) { }
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment