net.sourceforge.guacamole.net
Class GuacamoleTunnel

java.lang.Object
  extended by net.sourceforge.guacamole.net.GuacamoleTunnel

public class GuacamoleTunnel
extends Object

Provides a unique identifier and synchronized access to the GuacamoleReader and GuacamoleWriter associated with a GuacamoleSocket.

Author:
Michael Jumper

Constructor Summary
GuacamoleTunnel(GuacamoleSocket socket)
          Creates a new GuacamoleTunnel which synchronizes access to the Guacamole instruction stream associated with the given GuacamoleSocket.
 
Method Summary
 GuacamoleReader acquireReader()
          Acquires exclusive read access to the Guacamole instruction stream and returns a GuacamoleReader for reading from that stream.
 GuacamoleWriter acquireWriter()
          Acquires exclusive write access to the Guacamole instruction stream and returns a GuacamoleWriter for writing to that stream.
 void close()
          Release all resources allocated to this GuacamoleTunnel.
 GuacamoleSocket getSocket()
          Returns the GuacamoleSocket used by this GuacamoleTunnel for reading and writing.
 UUID getUUID()
          Returns the unique identifier associated with this GuacamoleTunnel.
 boolean hasQueuedReaderThreads()
          Returns whether there are threads waiting for read access to the Guacamole instruction stream.
 boolean hasQueuedWriterThreads()
          Returns whether there are threads waiting for write access to the Guacamole instruction stream.
 boolean isOpen()
          Returns whether this GuacamoleTunnel is open, or has been closed.
 void releaseReader()
          Relinquishes exclusive read access to the Guacamole instruction stream.
 void releaseWriter()
          Relinquishes exclusive write access to the Guacamole instruction stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GuacamoleTunnel

public GuacamoleTunnel(GuacamoleSocket socket)
Creates a new GuacamoleTunnel which synchronizes access to the Guacamole instruction stream associated with the given GuacamoleSocket.

Parameters:
socket - The GuacamoleSocket to provide synchronized access for.
Method Detail

acquireReader

public GuacamoleReader acquireReader()
Acquires exclusive read access to the Guacamole instruction stream and returns a GuacamoleReader for reading from that stream.

Returns:
A GuacamoleReader for reading from the Guacamole instruction stream.

releaseReader

public void releaseReader()
Relinquishes exclusive read access to the Guacamole instruction stream. This function should be called whenever a thread finishes using a GuacamoleTunnel's GuacamoleReader.


hasQueuedReaderThreads

public boolean hasQueuedReaderThreads()
Returns whether there are threads waiting for read access to the Guacamole instruction stream.

Returns:
true if threads are waiting for read access the Guacamole instruction stream, false otherwise.

acquireWriter

public GuacamoleWriter acquireWriter()
Acquires exclusive write access to the Guacamole instruction stream and returns a GuacamoleWriter for writing to that stream.

Returns:
A GuacamoleWriter for writing to the Guacamole instruction stream.

releaseWriter

public void releaseWriter()
Relinquishes exclusive write access to the Guacamole instruction stream. This function should be called whenever a thread finishes using a GuacamoleTunnel's GuacamoleWriter.


hasQueuedWriterThreads

public boolean hasQueuedWriterThreads()
Returns whether there are threads waiting for write access to the Guacamole instruction stream.

Returns:
true if threads are waiting for write access the Guacamole instruction stream, false otherwise.

getUUID

public UUID getUUID()
Returns the unique identifier associated with this GuacamoleTunnel.

Returns:
The unique identifier associated with this GuacamoleTunnel.

getSocket

public GuacamoleSocket getSocket()
Returns the GuacamoleSocket used by this GuacamoleTunnel for reading and writing.

Returns:
The GuacamoleSocket used by this GuacamoleTunnel.

close

public void close()
           throws GuacamoleException
Release all resources allocated to this GuacamoleTunnel.

Throws:
GuacamoleException - if an error occurs while releasing resources.

isOpen

public boolean isOpen()
Returns whether this GuacamoleTunnel is open, or has been closed.

Returns:
true if this GuacamoleTunnel is open, false if it is closed.


Copyright © 2012. All Rights Reserved.