pl.mn.communicator
Class DefaultConnectionService

java.lang.Object
  extended by pl.mn.communicator.DefaultConnectionService
All Implemented Interfaces:
IConnectionService

public class DefaultConnectionService
extends java.lang.Object
implements IConnectionService

The default implementation of IConnectionService.

Created on 2004-11-27

Version:
$Id: DefaultConnectionService.java,v 1.1 2005/11/05 23:34:52 winnetou25 Exp $
Author:
Mateusz Szczap

Constructor Summary
DefaultConnectionService(Session session)
           
 
Method Summary
 void addConnectionListener(ConnectionListener connectionListener)
          Adds ConnectionListener object to the list of listeners that will receive notification of connection related events.
 void addPacketListener(GGPacketListener packetListener)
          Adds GGPacketListener object to the list of listeners that will be notified of Gadu-Gadu packet related events.
 void addPingListener(PingListener pingListener)
           
 void connect(IServer server)
          Tries to connect to Gadu-Gadu server that has been previously assigned to Session instance.
 void disconnect()
          Tries to close the connection to the Gadu-Gadu server.
 IServer getServer()
          Get server user is currently connected to, returns null if user is not connected to any server.
 boolean isConnected()
          Method to check if we are connected or not.
 IServer lookupServer(int uin)
           
protected  void notifyConnectionClosed()
           
protected  void notifyConnectionError(java.lang.Exception ex)
           
protected  void notifyConnectionEstablished()
           
protected  void notifyPacketReceived(GGIncomingPackage incomingPackage)
           
protected  void notifyPacketSent(GGOutgoingPackage outgoingPackage)
           
protected  void notifyPingSent()
           
protected  void notifyPongReceived()
           
 void removeConnectionListener(ConnectionListener connectionListener)
          Remove ConnectionListener object from the list that will receive notification of connection related events.
 void removePacketListener(GGPacketListener packetListener)
          Remove GGPacketListener object from the list of listeners that will be notified of Gadu-Gadu packet related events.
 void removePingListener(PingListener pingListener)
           
protected  void sendPackage(GGOutgoingPackage outgoingPackage)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultConnectionService

DefaultConnectionService(Session session)
Method Detail

lookupServer

public IServer lookupServer(int uin)
                     throws GGException
Specified by:
lookupServer in interface IConnectionService
Throws:
GGException
See Also:
pl.mn.communicator.IConnectionService#getServer(int)

connect

public void connect(IServer server)
             throws GGException
Description copied from interface: IConnectionService
Tries to connect to Gadu-Gadu server that has been previously assigned to Session instance.

Specified by:
connect in interface IConnectionService
Throws:
GGException - if error occurs while connecting to Gadu-Gadu server.
GGSessionException - if there is an incorrect session state.
See Also:
pl.mn.communicator.IConnectionService#connect()

disconnect

public void disconnect()
                throws GGException
Description copied from interface: IConnectionService
Tries to close the connection to the Gadu-Gadu server.

Specified by:
disconnect in interface IConnectionService
Throws:
GGSessionException - if there is an incorrect session state.
GGException
See Also:
IConnectionService.disconnect()

isConnected

public boolean isConnected()
Description copied from interface: IConnectionService
Method to check if we are connected or not.

Specified by:
isConnected in interface IConnectionService
Returns:
boolean indicating whether we are connected or not.
See Also:
IConnectionService.isConnected()

getServer

public IServer getServer()
Description copied from interface: IConnectionService
Get server user is currently connected to, returns null if user is not connected to any server.

Specified by:
getServer in interface IConnectionService
Returns:
See Also:
IConnectionService.getServer()

addConnectionListener

public void addConnectionListener(ConnectionListener connectionListener)
Description copied from interface: IConnectionService
Adds ConnectionListener object to the list of listeners that will receive notification of connection related events.

Specified by:
addConnectionListener in interface IConnectionService
Parameters:
connectionListener - that will be added to the list of connection listeners.
See Also:
IConnectionService.addConnectionListener(pl.mn.communicator.event.ConnectionListener)

removeConnectionListener

public void removeConnectionListener(ConnectionListener connectionListener)
Description copied from interface: IConnectionService
Remove ConnectionListener object from the list that will receive notification of connection related events. The listener will no longer be notified of connection related events.

Specified by:
removeConnectionListener in interface IConnectionService
Parameters:
connectionListener - that will be removed from the list of connection listeners.
See Also:
IConnectionService.removeConnectionListener(pl.mn.communicator.event.ConnectionListener)

addPacketListener

public void addPacketListener(GGPacketListener packetListener)
Description copied from interface: IConnectionService
Adds GGPacketListener object to the list of listeners that will be notified of Gadu-Gadu packet related events.

Specified by:
addPacketListener in interface IConnectionService
Parameters:
packetListener - that will be added to the list of packet listeners.
See Also:
IConnectionService.addPacketListener(pl.mn.communicator.event.GGPacketListener)

removePacketListener

public void removePacketListener(GGPacketListener packetListener)
Description copied from interface: IConnectionService
Remove GGPacketListener object from the list of listeners that will be notified of Gadu-Gadu packet related events.

Specified by:
removePacketListener in interface IConnectionService
Parameters:
packetListener - that will be removed from the list of packet listeners.
See Also:
IConnectionService.removePacketListener(pl.mn.communicator.event.GGPacketListener)

addPingListener

public void addPingListener(PingListener pingListener)
Specified by:
addPingListener in interface IConnectionService
See Also:
IConnectionService.addPingListener(pl.mn.communicator.event.PingListener)

removePingListener

public void removePingListener(PingListener pingListener)
Specified by:
removePingListener in interface IConnectionService
See Also:
IConnectionService.removePingListener(pl.mn.communicator.event.PingListener)

notifyConnectionEstablished

protected void notifyConnectionEstablished()
                                    throws GGException
Throws:
GGException

notifyConnectionClosed

protected void notifyConnectionClosed()
                               throws GGException
Throws:
GGException

notifyConnectionError

protected void notifyConnectionError(java.lang.Exception ex)
                              throws GGException
Throws:
GGException

notifyPingSent

protected void notifyPingSent()

notifyPongReceived

protected void notifyPongReceived()

notifyPacketReceived

protected void notifyPacketReceived(GGIncomingPackage incomingPackage)

notifyPacketSent

protected void notifyPacketSent(GGOutgoingPackage outgoingPackage)

sendPackage

protected void sendPackage(GGOutgoingPackage outgoingPackage)
                    throws java.io.IOException
Throws:
java.io.IOException


Copyright 2004-2004-2005 SourceForge.net. All Rights Reserved.