@Override
    public void run() {
        byte[] header = new byte[Message.HEADER_SIZE];   ;
        byte[] data;
        try {
            in = new DataInputStream(clientSocket.getInputStream());
        } catch (IOException ex) {
            Logger.getLogger(TCPClient.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        System.out.println("Start Receiving");
        while(opened) {
            try {
                int readBytes = in.read(header);
                
                if((readBytes == Message.HEADER_SIZE) && (readBytes > 0)) {
                    num++;
                    Message msg = new Message();
                    msg.setHeaderBytes(header, GlobalStatus.getOrder());
                    
                    if(msg.getDataSize() > 0) {                        
                        data = new byte[msg.getDataSize()];
                        int readDataBytes = in.read(data);
                        if(readDataBytes == msg.getDataSize()) {
                            msg.setDataBytes(data);
                        }
                    }
                    
                    GlobalEventHandler.fireEvent(new GlobalEvent(GlobalEventTypes.TCP_RECV, msg));
                    
                    System.out.println("Client: "+num+":"+msg.toString());                    
                } else if(readBytes < 0) { //
                    close();
                } else {                    
                    JOptionPane.showMessageDialog(null, "Wrong number of bytes", "Error", JOptionPane.ERROR_MESSAGE);
                }
            } catch (IOException ex) {
                close();
                Logger.getLogger(TCPReceiver.class.getName()).log(Level.SEVERE, null, ex);                
            } 
        }
        System.out.println("Stop Receiving");
    }