Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.zeroconf
Class BonjourService

java.lang.Object
  extended by java.lang.Thread
      extended by net.java.sip.communicator.impl.protocol.zeroconf.BonjourService
All Implemented Interfaces:
Runnable, EventListener, DNSListener, ServiceListener

public class BonjourService
extends Thread
implements ServiceListener, DNSListener

Class dealing with JmDNS and treating all the incoming connections on the bonjour port

Author:
Christian Vincenot

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
(package private)  OperationSetPersistentPresenceZeroconfImpl opSetPersPresence
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
BonjourService(int port, ProtocolProviderServiceZeroconfImpl pps)
          Creates a new instance of the Bonjour service thread
 
Method Summary
 void addContact(ContactZeroconfImpl contact)
          Adds a contact to the locally stored list of contacts
 void changeStatus(PresenceStatus stat)
          Changes the status of the local user.
 Iterator<ContactZeroconfImpl> contacts()
          Returns an Iterator over all contacts.
 ContactZeroconfImpl getContact(String id, InetAddress ip)
          Returns the Contact with the specified identifier or IP address.
(package private)  String getID()
          Returns the id of this service.
 ProtocolProviderServiceZeroconfImpl getPPS()
          Returns the corresponding ProtocolProviderService
 void removeContact(String id, InetAddress ip)
          Removes the Contact with the specified identifier or IP address.
 void run()
          Walk?
 void serviceAdded(ServiceEvent event)
          A service has been added.
 void serviceRemoved(ServiceEvent event)
          A service has been removed.
 void serviceResolved(ServiceEvent event)
          A service has been resolved.
 void shutdown()
          Might be used for shutdown...
 void updateRecord(JmDNS jmdns, long now, DNSRecord record)
          Callback called by JmDNS to inform the BonjourService of a potential status change of some contacts.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

opSetPersPresence

OperationSetPersistentPresenceZeroconfImpl opSetPersPresence
Constructor Detail

BonjourService

public BonjourService(int port,
                      ProtocolProviderServiceZeroconfImpl pps)
Creates a new instance of the Bonjour service thread

Parameters:
port - TCP Port number on which to try to start the Bonjour service
pps - ProtocolProviderService instance which is creating this BonjourService
Method Detail

getPPS

public ProtocolProviderServiceZeroconfImpl getPPS()
Returns the corresponding ProtocolProviderService

Returns:
corresponding ProtocolProviderService

getID

String getID()
Returns the id of this service.

Returns:
returns the id of this service.

run

public void run()
Walk?

Specified by:
run in interface Runnable
Overrides:
run in class Thread

shutdown

public void shutdown()
Might be used for shutdown...


changeStatus

public void changeStatus(PresenceStatus stat)
Changes the status of the local user.

Parameters:
stat - New presence status

serviceAdded

public void serviceAdded(ServiceEvent event)
A service has been added.

Specified by:
serviceAdded in interface ServiceListener
Parameters:
event - The ServiceEvent providing the name and fully qualified type of the service.

serviceRemoved

public void serviceRemoved(ServiceEvent event)
A service has been removed.

Specified by:
serviceRemoved in interface ServiceListener
Parameters:
event - The ServiceEvent providing the name and fully qualified type of the service.

serviceResolved

public void serviceResolved(ServiceEvent event)
A service has been resolved. Its details are now available in the ServiceInfo record.

Specified by:
serviceResolved in interface ServiceListener
Parameters:
event - The ServiceEvent providing the name, the fully qualified type of the service, and the service info record, or null if the service could not be resolved.

updateRecord

public void updateRecord(JmDNS jmdns,
                         long now,
                         DNSRecord record)
Callback called by JmDNS to inform the BonjourService of a potential status change of some contacts.

Specified by:
updateRecord in interface DNSListener
Parameters:
jmdns - JmDNS instance responsible for this
now - Timestamp
record - DNSRecord which changed

contacts

public Iterator<ContactZeroconfImpl> contacts()
Returns an Iterator over all contacts.

Returns:
a java.util.Iterator over all contacts

addContact

public void addContact(ContactZeroconfImpl contact)
Adds a contact to the locally stored list of contacts

Parameters:
contact - Zeroconf Contact to add to the local list

getContact

public ContactZeroconfImpl getContact(String id,
                                      InetAddress ip)
Returns the Contact with the specified identifier or IP address.

Parameters:
id - the identifier of the Contact we are looking for.
ip - the IP address of the Contact we are looking for.
Returns:
the Contact with the specified id or address.

removeContact

public void removeContact(String id,
                          InetAddress ip)
Removes the Contact with the specified identifier or IP address.

Parameters:
id - the identifier of the Contact we are looking for.
ip - the IP address of the Contact we are looking for.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.