View Javadoc

1   /*------------------------------------------------------------------------------
2    * The contents of this file are subject to the Mozilla Public License Version
3    * 1.1 (the "License"); you may not use this file except in compliance with
4    * the License. You may obtain a copy of the License at
5    * http://www.mozilla.org/MPL/
6    * Software distributed under the License is distributed on an "AS IS" basis,
7    * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
8    * the specific language governing rights and limitations under the License.
9    *
10   * The Original Code is levelonelabs.com code.
11   * The Initial Developer of the Original Code is Level One Labs. Portions
12   * created by the Initial Developer are Copyright (C) 2001 the Initial
13   * Developer. All Rights Reserved.
14   *
15   *         Contributor(s):
16   *             Scott Oster      (ostersc@alum.rpi.edu)
17   *             Steve Zingelwicz (sez@po.cwru.edu)
18   *             William Gorman   (willgorman@hotmail.com)
19   *
20   * Alternatively, the contents of this file may be used under the terms of
21   * either the GNU General Public License Version 2 or later (the "GPL"), or
22   * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
23   * in which case the provisions of the GPL or the LGPL are applicable
24   * instead of those above. If you wish to allow use of your version of this
25   * file only under the terms of either the GPL or the LGPL, and not to allow
26   * others to use your version of this file under the terms of the NPL, indicate
27   * your decision by deleting the provisions above and replace them with the
28   * notice and other provisions required by the GPL or the LGPL. If you do not
29   * delete the provisions above, a recipient may use your version of this file
30   * under the terms of any one of the NPL, the GPL or the LGPL.
31   *----------------------------------------------------------------------------*/
32  
33  package com.levelonelabs.aim.example;
34  
35  import com.levelonelabs.aim.AIMAdapter;
36  import com.levelonelabs.aim.AIMBuddy;
37  import com.levelonelabs.aim.AIMClient;
38  import com.levelonelabs.aim.AIMSender;
39  
40  
41  /***
42   * Example of the simplicity of the new aim code
43   * 
44   * @author Scott Oster
45   * 
46   * @created January 12, 2002
47   */
48  public class EchoExample {
49  	/***
50  	 * The main program for the EchoExample class Starts up a aimclient and
51  	 * signs it on. Then registers a listener that gets called when someone
52  	 * messages the bot. It simply echos back what they said.
53  	 * 
54  	 * @param args
55  	 *            username password
56  	 */
57  	public static void main(String[] args) {
58  		//username, password, true indicates to add all that talk to it to the
59  		// buddy list
60  		final AIMSender aim = new AIMClient(args[0], args[1], "Simple Echo Bot", true);
61  		aim.addAIMListener(new AIMAdapter() {
62  			public void handleMessage(AIMBuddy buddy, String request) {
63  				aim.sendMessage(buddy, "Echo: " + request);
64  			}
65  		});
66  		aim.signOn();
67  	}
68  }