home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / in4wjcxu / src / como / sys / comobj.java next >
Encoding:
Java Source  |  1996-08-14  |  4.5 KB  |  162 lines

  1. /*
  2. * @(#)ComObj.java    1.0 95/11/09 Ulrich Gall & Jan Kautz
  3. *
  4. * Copyright (c) 1996 Ulrich Gall & Jan Kautz 
  5. * uhgall@cip.informatik.uni-erlangen.de
  6. * Hofmannstr. 48, D-91052 Erlangen, Germany, Fax: +49-9131-201358
  7. *
  8. * Permission to use, copy, and distribute this software
  9. * and its documentation for NON-COMMERCIAL purposes and without
  10. * fee is hereby granted provided that this copyright notice
  11. * appears in all copies. Please contact us for  further copyright 
  12. * and licensing information.
  13. *
  14. * WE MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  15. * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  16. * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  17. * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. WE SHALL NOT BE LIABLE FOR
  18. * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  19. * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  20. */
  21.  
  22. package como.sys;
  23.  
  24. import java.util.*;
  25. import java.awt.Image;
  26. import java.applet.*;
  27. import java.io.InputStream;
  28.  
  29. /**
  30. * This is an interface for "Communicator" - objects that provides methods for Commlets 
  31. * to send messages to the other Commlet instances.
  32. */
  33. public interface ComObj {
  34.  
  35.     /**
  36.      * get the ID of myself.
  37.      * @return the local user's ID.
  38.      */
  39.     public int getMyID();
  40.  
  41.     /**
  42.      * get the ID of master.
  43.      * @return the masters user's ID.
  44.      * -1 means: it is still unknown. Wait for the NEW_MASTER-message.
  45.      */
  46.     public int getMasterID();
  47.  
  48.     /**
  49.     * Get more information about the user with the given id.
  50.     * @param id the id of the user.
  51.     * @return the information about the User
  52.     */
  53.     public User getUser( int id );    
  54.     
  55.     /**
  56.     * get the name of given user with ID id.
  57.     * @return the name of the user
  58.     */
  59.     public String getUserName( int id );
  60.  
  61.     /**
  62.     * get all Users in the commlet.
  63.     * @return a Vector with all Users (User-Object)
  64.     */
  65.     public Vector getUsers();
  66.  
  67.     /**
  68.     * Sets the local User to u. Certain fields can not be changed, such as the nickname etc.
  69.     * Those will simply stay the same
  70.     * @param newUser. A User-Object containig the new information.
  71.     */
  72.     public void setLocalUser(User newUser);
  73.  
  74.     /** 
  75.     * Set a new topic. The Commlet has to decide if it may be set or not
  76.     * -- if this method is called, the topic WILL be set.
  77.     * @param topic the new topic.
  78.     */
  79.     public void setNewTopic(String topic);
  80.  
  81.     /**
  82.     * Returns true if this Commlet is the "Master". Exactly one Commlet instance in a
  83.     * communication is "Master" at any given time.
  84.     * @return true if master, false if not.
  85.     */
  86.     public boolean iAmMaster();
  87.  
  88.     /**
  89.     * Sends a message to msg.from
  90.     * @param msg the msg you want to send.
  91.     */
  92.     public void sendTo( Msg msg );
  93.  
  94.     /**
  95.     * Sends a message to the other Commlet instances, but not to this one.
  96.     * @param msg the msg you want to send.
  97.     */
  98.     public void sendToOthers( Msg msg );
  99.  
  100.     /**
  101.     * Sends a message to the Commlet instances contained in the byte array to[].
  102.     * @param to array of user-ids where to send the message to.
  103.     * @param msg the msg you want to send.
  104.     */
  105.     public void sendToGroup(int[] to,Msg msg );
  106.     
  107.     /**
  108.     * Sends a message to all Commlet instances, including this one.
  109.     * @param msg the msg you want to send.
  110.     */
  111.     public void sendToAll( Msg msg );
  112.  
  113.     /**
  114.     * Sends msg to msg.to and blocks until msg.to answers.
  115.     * The answer message is returned!
  116.     * Do not use this method very often. It usually take's a long time
  117.     * to return!!! If you respond to a ask-message, call msg.setAnswer( true );
  118.     * @param msg the msg you want to send.
  119.     * @return msg the answer-msg.
  120.     */
  121.     public Msg ask( Msg msg );
  122.  
  123.     /**
  124.     * Kick a User out of the channel. Do not use this too often :-)
  125.     * Commlet-Writers: Only let the master kick a user, please.
  126.     * @param id the id of the user
  127.     * @param reason the reason why he was kicked out
  128.     */
  129.     public void kickUser( int id, String reason );
  130.  
  131.     /**
  132.     * Should be called by commlet.stop() to inform others that
  133.     * the user is leaving to communication.
  134.     */
  135.     public void logout();
  136.  
  137.     /**
  138.      * Load a picture with the specified filename!
  139.      * The ComObj has to know where to get it!
  140.      * @param filename the name of the file
  141.      * @return the Image.
  142.      */
  143.     public Image loadImage( String filename );
  144.  
  145.     /**
  146.      * Load an audioclip with the specified filename!
  147.      * The ComObj has to know where to get it!
  148.      * @param filename the name of the file
  149.      * @return the AudioClip.
  150.      */
  151.     public AudioClip loadAudioClip( String filename );
  152.  
  153.     /**
  154.      * Open an input-stream to the specified file!
  155.      * The ComObj has to know where to get it!
  156.      * @param filename the name of the file
  157.      * @return the InputStream for that file.
  158.      */
  159.     public InputStream openInputStream( String filename );
  160. }
  161.  
  162.