import java.rmi.*;
import java.rmi.server.*;
import java.io.*;

public class PingPongServer extends UnicastRemoteObject implements PingPong
{
	public static void main(String[] args)
	{
		System.setSecurityManager(new RMISecurityManager());
		try
		{
			PingPong ts = new PingPongServer();
			System.out.println("Server instantiated");
			Naming.rebind("PingPongServer", ts);
			System.out.println("Server bound");
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
	
	public PingPongServer() throws RemoteException
	{
		super();
	}
	
	public String ping() throws RemoteException
	{
		System.out.println("ping");
		return "ping";
	}

	public char pong(char c) throws RemoteException
	{
		System.out.println("pong");
		return c;
	}

	public byte[] bong(String stuff) throws RemoteException
	{
		System.out.println("bong");
		return stuff.getBytes();
	}
}
