Jriver/
Jriver/src/org/jriver/core/
Jriver/src/org/jriver/core/interactive/
Jriver/src/org/jriver/lib/
Jriver/src/org/jriver/lib/daemon/
Jriver/src/org/jriver/lib/events/
Jriver/src/org/jriver/lib/interfaces/
Jriver/src/org/jriver/lib/std/
Jriver/src/org/jriver/telnet/
Jriver/src/org/jriver/telnet/.svn/
Jriver/src/org/jriver/telnet/.svn/prop-base/
Jriver/src/org/jriver/telnet/.svn/text-base/
/*
 * Copyright 2007 Kevin Roe, Daniel McCarney
 * This file is part of Jriver.
 *
 * Jriver is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Jriver is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.jriver.telnet;


import java.net.*;
import java.io.*;

import org.jriver.lib.Authenticator;


public class ConnectionThread implements Runnable
{
	private Socket	socket	= null;

	public ConnectionThread(Socket socket)
	{
		this.socket = socket;
	}

	public void closeConnection(String[] args)
	{
		try
		{
			socket.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return;
	}

	public void run()
	{
		try
		{
			PrintWriter out = new PrintWriter(
					socket.getOutputStream(), true);

			String outputLine;
			TelnetProtocol tp = new TelnetProtocol(socket);

			/** 
			 * TODO: implement telnet protocol pre-processing on input and get a string
			 */ 
			outputLine = tp.processInput(null);
			out.println(outputLine);
			
			Authenticator newLogin = new Authenticator();
			newLogin.setInteractivity(socket);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}