Package commoms

Examples of commoms.CommandIF


  ppp:    for (Enumeration e = getoutputStreams(); e.hasMoreElements();) {
    // ... get the output stream ...
    ObjectOutputStream dout = (ObjectOutputStream) e.nextElement();
    // ... and send the message
   
    CommandIF com = makeCommandForConfirmation(command.getRecipientNames());
    try {
        dout.writeObject(com);
      
        ObjectInputStream ois = serverThread.getDin();
        synchronized (ois) {
        CommandIF com1 = null;
        while (true) {
        com1 = (CommandIF) ois.readObject();
        if(!com1.isConfirmation()) {
      break ppp;
        }
        if(com1.isConfirmation()) {
      dout.writeObject(command);
      return;
        }
        }
       }//sync
View Full Code Here


  // Synchronize so we don't mess up sendToAll() while it walks
  // down the list of all output streamsa
  synchronized (outputStreams) {
      // Tell the world
      log.error("Removing connection to " + senderName);
      CommandIF comm = updateRemovedPeerList(senderName, s);
      // Remove it from our hashtable/list
      outputStreams.remove(s);
      // Make sure it's closed
      try {
    s.close();
View Full Code Here

      // don't do anything
  }
  if ((userId != null) && (!userId.equals("")) && (!userId.equals("null")) && (!peers.containsKey(userId))) {
      peers.put(userId, store);
      // send message to all.
      CommandIF comm = makeCommandOfPeerList();
      comm.setMessage(userId + " joined in!\n");
      sendToAll(comm);
  }// if
    }
View Full Code Here

    // while removing
    CommandIF updateRemovedPeerList(String userName, Socket store) {

  peers.remove(userName);

  CommandIF comm = makeCommandOfPeerList();
  comm.setMessage(" " + userName + " gone away!\n");
  return comm;
    }
View Full Code Here

try {

  jt.setEditable(true);
  while (true) {
    CommandIF comm = (CommandIF) din.readObject();
    // for reading normal messages
    if (comm.getCommand().equals(ProtocolConstants.COMMAND_SEND)) {
      boolean show = (!comm.isPrivateMessage())
          || comm.getMsgFrom().equals(sendername);
      Iterator itr = comm.getRecipientNames().iterator();
      boolean flag = false;
      mess = comm.getMessage();
      while (itr.hasNext()) {
        if (itr.next().toString().equals(sendername)) {
          flag = true;
          mess = "   (private message)\n" + mess;
        }
      }
      show = show || flag;
      if (show) {
        //mess = comm.getMessage();
        jt.append(mess + "\n");
      }
    }// if
   
           // for updating peer list.
    if (comm.getCommand().equals(ProtocolConstants.UPDATE_PEER_LIST)) {
      List list = comm.getNewPeerList();
      ch.removeAll();
      Iterator itr = list.iterator();
      ch.addItem(ProtocolConstants.SEND_TO_ALL);
      while(itr.hasNext()) {
          ch.addItem(itr.next().toString());
      }
      mess = comm.getMessage();
      jt.append(mess + "\n");
    }//if
   
    jt.setEditable(false);
  }
View Full Code Here

  loginSound = getAudioClip(getDocumentBase(), "resources/login.wav");
  recieveSound = getAudioClip(getDocumentBase(), "resources/receive.wav");
  alertSound = getAudioClip(getDocumentBase(), "resources/alert.wav");
  ac = new AppletConnection(server, port, this);
  ac.start();
  CommandIF com = makeCommandForSendToAllMessage(sendername,
    "welcome here\n");
  ac.sendMessage(com);
    }
View Full Code Here

    icon8.setImage(image8);
    muteButton.setToolTipText("Mute on");
      }
  } else if (s.equals(sendFileText)) {
      System.out.println("User is trying to send file");
      CommandIF comm = makeSendFileCommand();
      if (null != comm) {
    ac.sendMessage(comm);
      }// if
  } else if (s.equals(acceptText)) {
      acceptFile = true;
View Full Code Here

  try {
      mess = jta.getText();
      if ("".equals(mess.trim())) {
    return;
      }
      CommandIF comm = null;
      if ((null == privateMsgTo) || ("".equals(privateMsgTo))) {
    privateMsgTo = ProtocolConstants.SEND_TO_ALL;
      }
      if (privateMsgTo.equals(ProtocolConstants.SEND_TO_ALL)) {
    comm = makeCommandForSendToAllMessage(sendername, mess);
View Full Code Here

}

private void sendMessage() {
try {
  mess = tf.getText();
  CommandIF comm = null;
  if ((null == privateMsgTo) || ("".equals(privateMsgTo))) {
    privateMsgTo = ProtocolConstants.SEND_TO_ALL;
  }
  if (privateMsgTo.equals(ProtocolConstants.SEND_TO_ALL)) {
    comm = makeCommandForSendToAllMessage(sendername, mess);
View Full Code Here

jb = new Button("send");
jb.addActionListener(this);

add(jb);
CommandIF com = makeCommandForSendToAllMessage(sendername,
    "Hi");
try {
  dout.writeObject(com);
} catch (IOException e) {
  e.printStackTrace();
View Full Code Here

TOP

Related Classes of commoms.CommandIF

Copyright © 2018 www.massapicom. 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.