package org.apache.commons.net.ssh;

import java.io.InterruptedIOException;
import java.nio.ByteBuffer;
import java.security.KeyPair;
import java.util.concurrent.SynchronousQueue;

import org.apache.commons.net.SocketClient;
import org.apache.commons.net.ssh.util.Buffer;

public class ClientSession extends SocketClient implements Runnable
{
    String username;
    SynchronousQueue<ByteBuffer> outPackets = new SynchronousQueue<ByteBuffer>();
    
    public boolean authPassword(String password)
    {
        return false;
    }
    
    public boolean authPublickey(KeyPair[] keypairs)
    {
        return false;
    }
    
    private ByteBuffer encode(Buffer buf)
    {
        
        return null;
    }
    
    public void run()
    {
        // take from outPackets and write to server
        // get from server and handle them:
        // - will be either packets to be handled here e.g. key reexchange
        // - channel data - write to that channel's output stream in that case
        // throw exception on close
    }
    
    public synchronized void send(Buffer payload) throws InterruptedIOException
    {
        try
        {
            outPackets.put(encode(payload));
        }
        catch (InterruptedException e)
        {
            InterruptedIOException ioe = new InterruptedIOException();
            ioe.initCause(e);
            throw ioe;
        }
    }
    
    public void setUsername(String username)
    {
        this.username = username;
    }
    
}

@@ -749,18 +749,55 @@
         
-//
+while (true)%0A        %7B%0A            // *
  take fr
@@ -842,14 +842,28 @@
     
-// g
+    // * for pack
 et
+s
  fro
@@ -874,26 +874,13 @@
 rver
- and handle them:%0A
+%0A    
     
@@ -885,16 +885,18 @@
       //
+  
  - will 
@@ -931,12 +931,44 @@
 led 
-here
+in this thread's context immediately
  e.g
@@ -984,16 +984,20 @@
 xchange%0A
+    
         
@@ -1003,111 +1003,167 @@
  // 
-- channel data -
+  - data for a specific channel: will be
  writ
+t
 e
+n
  to 
-that channel's out
+its in
 put
- 
 stream
- in that case%0A        // throw exception on close
+%0A            // * on session close -- close events go to the channels' streams (?)%0A        %7D
 %0A   

clarify the comment in ClientSession.run()