[Zerofile-svn] SF.net SVN: zerofile: [54] trunk/src
Status: Pre-Alpha
Brought to you by:
karl-bengtsson
|
From: <kar...@us...> - 2007-11-21 11:53:10
|
Revision: 54
http://zerofile.svn.sourceforge.net/zerofile/?rev=54&view=rev
Author: karl-bengtsson
Date: 2007-11-21 03:53:15 -0800 (Wed, 21 Nov 2007)
Log Message:
-----------
Ugly as fuck patch to solve the problem of our registered service name not being set until after browsing begins - getMyServiceName now sleeps until service name is set. DO NOT CALL GETMYSERVICENAME() WITHOUT HAVING STARTED REGISTRATION OR YOU WILL DIE
Modified Paths:
--------------
trunk/src/ZeroconfBrowsing.java
trunk/src/ZeroconfRegistration.java
Modified: trunk/src/ZeroconfBrowsing.java
===================================================================
--- trunk/src/ZeroconfBrowsing.java 2007-11-21 11:01:21 UTC (rev 53)
+++ trunk/src/ZeroconfBrowsing.java 2007-11-21 11:53:15 UTC (rev 54)
@@ -15,7 +15,7 @@
String name, String regType, String domain)
{
XMPPLinkLocalHost newHost = new XMPPLinkLocalHost(name);
- if (!ZeroFileMainWindow.containsHost(newHost) && !ZeroFile.getServiceName().equals(name))
+ if (!ZeroFileMainWindow.containsHost(newHost) && !ZeroconfRegistration.getMyServiceName().equals(name))
{
newHost.updateData();
ZeroFileMainWindow.addHost(newHost);
Modified: trunk/src/ZeroconfRegistration.java
===================================================================
--- trunk/src/ZeroconfRegistration.java 2007-11-21 11:01:21 UTC (rev 53)
+++ trunk/src/ZeroconfRegistration.java 2007-11-21 11:53:15 UTC (rev 54)
@@ -9,23 +9,20 @@
{
private static TXTRecord _txtRecord = new TXTRecord();
private static DNSSDRegistration _r;
+ private static String _myServiceName;
static void registerService(String status,int port)
throws DNSSDException, InterruptedException
{
- _r = DNSSD.register(ZeroFile.getServiceName(), "_presence._tcp", port, new RegisterListener()
+ _r = DNSSD.register(null, "_presence._tcp", port, new RegisterListener()
{
public void serviceRegistered(DNSSDRegistration registration, int flags,
String serviceName, String regType, String domain)
{
- // TODO
- System.out.println("Registered Name : " + serviceName);
- System.out.println(" Type : " + regType);
- System.out.println(" Domain: " + domain);
+ _myServiceName = serviceName;
}
public void operationFailed(DNSSDService service, int errorCode)
{
- // TODO
System.out.println("Registration failed: " + errorCode);
}
});
@@ -36,6 +33,17 @@
_r.getTXTRecord().update(0, _txtRecord.getRawBytes(), 0);
}
+ public static String getMyServiceName()
+ {
+ while (_myServiceName == null)
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return _myServiceName;
+ }
+
static void registerService(int port)
throws DNSSDException, InterruptedException
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|