Package org.mitre.sipchat.model.presence

Source Code of org.mitre.sipchat.model.presence.PresenceMulticaster

/*
* This file is part of the Java SIP library, an open source SIP library. Please see
* http://collaboration.mitre.org/sip for more information
*
* Copyright (c) 2001 The MITRE Corporation
*
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
* License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB.  If not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*
*/
/**
* Maintains listener list for CallEvents
*
* @author S.R.Jones
* @version 1
*/

package org.mitre.sipchat.model.presence;

import java.awt.AWTEventMulticaster;
import java.util.EventListener;

public class PresenceMulticaster extends AWTEventMulticaster implements PresenceListener
{
    protected PresenceMulticaster( EventListener a, EventListener b ) {
  super( a, b );
    }

    public static PresenceListener add( PresenceListener a, PresenceListener b ) {
  return (PresenceListener) addInternal( a, b );
    }

    public static PresenceListener remove( PresenceListener cel,
            PresenceListener cel_old )
    {
  return (PresenceListener) removeInternal( cel, cel_old );
    }

    public void subscribeReceived( PresenceEvent pe ) {
  if ( a != null ) ( (PresenceListener) a ).subscribeReceived(pe);
  if ( b != null ) ( (PresenceListener) b ).subscribeReceived(pe);
    }

    public void notifyReceived( PresenceEvent pe ) {
  if ( a != null ) ( (PresenceListener) a ).notifyReceived(pe);
  if ( b != null ) ( (PresenceListener) b ).notifyReceived(pe);
    }
 

    protected static EventListener addInternal( EventListener a, EventListener b ) {
  if ( a == null ) return b;
  if ( b == null ) return a;

  return new PresenceMulticaster( a, b );
    }

    protected EventListener remove( EventListener old_listener ) {
  if ( old_listener == a ) return b;
  if ( old_listener == b ) return a;

  EventListener a2 = removeInternal(a, old_listener);
  EventListener b2 = removeInternal(b, old_listener);

  if ( a2 == a && b2 == b ) return this;
  return addInternal( a2, b2 );
    }
}
TOP

Related Classes of org.mitre.sipchat.model.presence.PresenceMulticaster

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.