@Override
	public void run(){
		try{
			o = sock.getOutputStream();
			i = sock.getInputStream();
			while(running()){
				if(!buffer.isEmpty()){
					String message = buffer.remove(0);
					write(message);
					o.flush();
					//Risk.showMessage(message);
					System.out.println("Message written");
				}
				if(i.available() > 1){
					String message = new String(read(), Charset.forName("UTF-8"));
					if("!!!!!!!!".equals(message)){
						System.err.println("Connected client has stopped, EXIT NOW");
						System.exit(-10);
					}
					//Risk.showMessage(message);
					useMessage(message);
					System.out.println("Message received: " + message);
				}
				try {
					Thread.sleep(50);
				} catch (InterruptedException e) {
					//e.printStackTrace();
				}
			}
		}
		catch (IOException e) {
			e.printStackTrace();
		}
		catch(Exception e){
			e.printStackTrace();
		}
		finally{
			try {
				sock.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}