public void run(){

		try {
			writer = new PrintWriter(socket.getOutputStream(), true);
			reader = new BufferedReader(new InputStreamReader(System.in));	
			String input;			
			System.out.println("READY for Input!");

			
			while((input = reader.readLine()) != null) {

				if(input.equals("!end")) {					
					if(!ClientStatus.getInstance().getUser().equals("")){
						writer.println(StaticStream.getStaticStreamInstance().useEncoder("!logout"));
					}
					ClientStatus.getInstance().setKill(true);
					break;
				}
				else{
					if(input.length()>0){
						String query=parser.parse(input.trim());
						if(query.length()>1 && !ClientStatus.getInstance().isBlocked()){

							ClientStatus.getInstance().setLastCommand(query);
							query = StaticStream.getStaticStreamInstance().useEncoder(query);

							writer.println(query);
						}
					}
					else System.out.println("");
				}
			}
		}catch(SocketException e){
			System.out.println("socket gone");
			return;
		}
		catch (IOException e) {
			e.printStackTrace();
			System.out.println("IO:....");
			//socket=null;
			return;
		}
		finally{
			if(!socket.isClosed())
				close();
		}

	}