/*********************************************************************
* AddressClient.java
* created on 17.03.2005 by netseeker
* $Source: /cvsroot/ejoe/EJOE/examples/de/netseeker/ejoe/examples/echo/EchoClient.java,v $
* $Date: 2007/11/17 10:59:56 $
* $Revision: 1.8 $
*********************************************************************/
package de.netseeker.ejoe.examples.echo;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import de.netseeker.ejoe.EJClient;
import de.netseeker.ejoe.adapter.UTF8StringAdapter;
/**
* Simple Example showing how to implement a basic ECHO client with EJOE.
*
* @author netseeker
*/
public class EchoClient
{
public static void main( String[] args )
{
EJClient client = new EJClient( "localhost", 9999, new UTF8StringAdapter() );
client.enablePersistentConnection( true );
try
{
BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) );
String str = "", result = null;
while ( str != null )
{
System.out.print( "> type your message: " );
str = in.readLine();
if ( str != null )
{
if ( str.equalsIgnoreCase( "exit" ) )
{
System.out.println( "Bye." );
client.close();
System.exit( 1 );
}
if ( str.length() > 0 )
{
result = (String) client.execute( str );
System.out.println( "Server returned: " + result );
}
}
}
}
catch ( IOException e )
{
e.printStackTrace();
}
}
}