Package Communication.Mocks

Source Code of Communication.Mocks.ICQSimulation

package Communication.Mocks;

import java.util.Timer;
import java.util.TimerTask;

import Communication.ChatProvider;
import Communication.GeneralConnection;
import Communication.Status;
import Control.Contact;
import Control.Interfaces.EventHandler;

/**
* A mock object emulating an ICQ instance.
*
* @author Sebastian
*
*/
public class ICQSimulation extends GeneralConnection{

  private Timer timer;

  public ICQSimulation(String uin, String password, EventHandler eventHandler, ChatProvider chatProvider) {
    super(uin, password, ChatProvider.ICQ, eventHandler);

  }
 
  public void connect() {
   
    timer = new Timer();
    timer.schedule(new TimerTask(){

      public void run() {

        eventHandler.addNewContact(new Contact("212245243", ChatProvider.ICQ, Status.Online, "Sebastian", ""));
        eventHandler.addNewContact(new Contact("894534434",
            ChatProvider.ICQ, Status.Invisible, "Vanessa", ""));
        eventHandler.addNewContact(new Contact("345244675", ChatProvider.ICQ, Status.Offline, "Felix", ""));

        eventHandler.connectionToProviderEstablished(ChatProvider.ICQ);
      }}, 3000);
  }

 
  public void quit() {

  }

 
  public void stopLogin() {
   
    if(timer != null){
      timer.cancel();
    }
  }
}
TOP

Related Classes of Communication.Mocks.ICQSimulation

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.