public void ReadMassage() {
            
            try {
              
     
                
               
                ReadSelector.selectNow();
                
                Set readyKeys = ReadSelector.selectedKeys();
                
                Iterator i = readyKeys.iterator();
                
                
                while (i.hasNext()) {
                  
                   
                     if(isFirst_Phase_over()&&(!isDecrypted())&&(!isThird_phhase_over()))
                {
                    System.out.println("key size is"+readyKeys.size());
                    Read_Enrypted_Massage(ReadSelector,ChatBox,SChan, i);
                    break;
                }
               else
                     {
                          System.out.println("key size is------"+readyKeys.size());
                    SelectionKey key = (SelectionKey) i.next();
                    i.remove();
                    SocketChannel channel = (SocketChannel) key.channel();
                    ReadBuffer.clear();
                    
                    
                    long nbytes = channel.read(ReadBuffer);
                    
                    if (nbytes == -1) {
                        ChatBox.append("You logged out !\n");
                        channel.close();
                    } else {
                          
                        StringBuffer sb = (StringBuffer)key.attachment();
                        
                        ReadBuffer.flip( );
                        String str = asciiDecoder.decode( ReadBuffer).toString( );
                        sb.append( str );
                        ReadBuffer.clear( );
                        
                       
                        String line = sb.toString();
                        
                        if ((line.indexOf("\n") != -1) || (line.indexOf("\r") != -1)) {
                            line = line.trim();
                            System.out.println("Message Received");
                            System.out.println(line);
                            setThird_phhase_over(false);
                           
                            ChatBox.append("> "+ line);
                            ChatBox.append(""+'\n');
                            sb.delete(0,sb.length());
                           
                        }
                    }
                }
                } 
            } catch (IOException ioe) {
            } catch (Exception e) {
            }
        }