// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   BoggleClient.java

import java.io.*;
import java.net.Socket;
import java.net.UnknownHostException;

public class BoggleClient
{

    public BoggleClient()
    {
        playerSocket = null;
        in = null;
        out = null;
    }

    public BoggleGrid getServerGrid(String s, int i)
    {
        BoggleGrid bogglegrid = null;
        try
        {
            playerSocket = new Socket(s, i);
            in = new ObjectInputStream(playerSocket.getInputStream());
            bogglegrid = (BoggleGrid)in.readObject();
            in.close();
            playerSocket.close();
        }
        catch(ClassNotFoundException _ex)
        {
            System.err.println("Serialized class not recognised");
            return null;
        }
        catch(UnknownHostException _ex)
        {
            System.err.println("Don't know about host: " + s);
            return null;
        }
        catch(IOException _ex)
        {
            System.err.println("Couldn't get I/O for the connection to: " + i);
            return null;
        }
        return bogglegrid;
    }

    public BoggleHiScoreSet getServerHiScore(String s, int i)
    {
        BoggleHiScoreSet bogglehiscoreset = null;
        try
        {
            playerSocket = new Socket(s, i);
            in = new ObjectInputStream(playerSocket.getInputStream());
            bogglehiscoreset = (BoggleHiScoreSet)in.readObject();
            in.close();
            playerSocket.close();
        }
        catch(ClassNotFoundException _ex)
        {
            System.err.println("Serialized class not recognised");
            System.exit(1);
        }
        catch(UnknownHostException _ex)
        {
            System.err.println("Don't know about host: " + s);
            System.exit(1);
        }
        catch(IOException _ex)
        {
            System.err.println("Couldn't get I/O for the connection to: " + i);
            System.exit(1);
        }
        return bogglehiscoreset;
    }

    public boolean submitScore(String s, int i, BoggleScore bogglescore)
    {
        try
        {
            playerSocket = new Socket(s, i);
            out = new ObjectOutputStream(playerSocket.getOutputStream());
            out.writeObject(bogglescore);
            out.close();
            playerSocket.close();
        }
        catch(UnknownHostException _ex)
        {
            System.err.println("Don't know about host: " + s);
            System.exit(1);
        }
        catch(IOException _ex)
        {
            System.err.println("Couldn't get I/O for the connection to: " + i);
            System.exit(1);
        }
        return true;
    }

    Socket playerSocket;
    ObjectInputStream in;
    ObjectOutputStream out;
}
