drastic.mCmdIF
Class VVWNETCMDSENDER

java.lang.Object
  extended bydrastic.mCmdIF.VVWNETCMDSENDER

public class VVWNETCMDSENDER
extends java.lang.Object

Title: VVWNetCmdSender (low level - use MediaCmdIF instead)

Description: Send VVW MediaCmd s through a network TCP-IP socket interface to a remote VVW/Titan or network enabled QuickClip. Handles the send and receive through a direct socket, or through the socket manager.

MediaCmdIF - Main Interface API - uses MediaCmd and VVWNetCmdSender
MediaCmd - Structure sent and returned from the VVW
VVWNETCMDSENDER - used to send and receive the MediaCmds

Company: Drastic Technologies Ltd.
523 The Queensway, Suite 102
Toronto, ON, M8Y 1J7
CANADA
416 255 5636
fax 255 8780
http://www.drastictech.com
engineering@drastictech.com

Version:
1.0
Author:
Dean Mitrovich
See Also:
MediaCmd, MediaCmdIF, SocketManager

Field Summary
 long dwCmdTimeMs
          Millisecond time the last command was sent
(package private)  int dwStreamErrors
          Total stream errors since connect
(package private)  boolean m_bLastCmdOK
          If true, then the last command sent was sent are a response was recieved
private  boolean m_bValid
          If true, then this sender is connected to a vvw and communicating
private  long m_Channel
          Current channel the net sender is communicating with within the remote vvw
private  boolean m_connected
          If true, then this sender's tcp/ip socket is connected to the remote machine
(package private)  java.io.DataInputStream m_DataInputStream
          Input data stream used for communication through socket
(package private)  java.io.DataOutputStream m_DataOutputStream
          Output data stream used for communication through socket
(package private)  java.util.Date m_Date
          Current date
(package private)  int m_dwPort
          Socket port to connect on
private  long m_dwSemiUnique
          Internal: A unique number to attach to a command
private static boolean m_fInUse_SocketLocket
          Only for SocketLocket, do not use outside this function.
(package private)  java.net.InetAddress m_inetAddr
          InetAddress Class represents the IP address as an unsigned 32 bit number used by the IP
(package private)  java.net.InetSocketAddress m_InetSocketAddress
          The socket address
private  boolean m_NotReady
          If True, the sender is not ready to send another command.
(package private)  java.lang.String m_szError
          Last error message
private  java.net.Socket m_TCSocket
          Used to connect to a foriegn host at a specified port
private  int m_timeOut
          Default time out.
(package private)  SocketManager socketMgr
          Shared socket manager
 
Constructor Summary
VVWNETCMDSENDER()
          VVWNETCMDSENDER - Default, do not use
VVWNETCMDSENDER(SocketManager socketManager)
          VVWNETCMDSENDER - Creates sender and keeps reference to socket manager
 
Method Summary
private  int BytesAvailable()
          BytesAvailable - number of bytes available in the input data stream
 void Disconnect(boolean fCloseAllInst)
          Disconnects the connection established by socket
(package private)  boolean fInUse()
          fInUse - Is the socket currently locked and in use
 long getChannel()
          getChannel
 boolean IsConnected()
          IsConnected - Are we currently connected through the socket
 boolean IsFirstConnect()
          IsFirstConnect - Is this the first time we have connected to this machine, or are we going to reuse a currently connected socket.
 boolean IsReady()
          IsReady - Is our connection ready to receive commands
 boolean IsValid()
          IsValid - Is our connection currently valid
(package private)  boolean LockSocket()
          LockSocket - Lock the socket for exclusive use
 boolean SendVvwCmd(long lChannel, MEDIACMD mCmd)
          This sends a MediaCmd command to any channel in the VVW we are connected to/
 boolean SendVvwCmd(MEDIACMD mCmd)
          Sends a command to the current channel
 void setChannel(long channel)
          Sets the current channel in use by the applet
 void setTimeout(int nTimeout)
          setTimeout for the low level socket
private  boolean SocketLocket(boolean fCheck, boolean fLock)
          SocketLocket - Lock a socket for exclusive use
 int StreamErrors()
          StreamErrors - Total stream errors since we first instantiated
 boolean TryConnect(java.lang.String szIpAddress, int dwPort)
          Attempts to establish a connection to the specified server at the specified port.
(package private)  boolean UnLockSocket()
          UnLockSocket - Unlock the socket, allow others access
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dwCmdTimeMs

public long dwCmdTimeMs
Millisecond time the last command was sent


m_dwPort

int m_dwPort
Socket port to connect on


m_szError

java.lang.String m_szError
Last error message


m_inetAddr

java.net.InetAddress m_inetAddr
InetAddress Class represents the IP address as an unsigned 32 bit number used by the IP


m_TCSocket

private java.net.Socket m_TCSocket
Used to connect to a foriegn host at a specified port


m_InetSocketAddress

java.net.InetSocketAddress m_InetSocketAddress
The socket address


socketMgr

SocketManager socketMgr
Shared socket manager


m_DataInputStream

java.io.DataInputStream m_DataInputStream
Input data stream used for communication through socket


m_DataOutputStream

java.io.DataOutputStream m_DataOutputStream
Output data stream used for communication through socket


m_bValid

private boolean m_bValid
If true, then this sender is connected to a vvw and communicating


m_connected

private boolean m_connected
If true, then this sender's tcp/ip socket is connected to the remote machine


m_bLastCmdOK

boolean m_bLastCmdOK
If true, then the last command sent was sent are a response was recieved


m_NotReady

private boolean m_NotReady
If True, the sender is not ready to send another command. Normally this is because it is already processing a command


dwStreamErrors

int dwStreamErrors
Total stream errors since connect


m_Channel

private long m_Channel
Current channel the net sender is communicating with within the remote vvw


m_timeOut

private int m_timeOut
Default time out. Length in milliseconds to wait for a reponse from the remote machine


m_dwSemiUnique

private long m_dwSemiUnique
Internal: A unique number to attach to a command


m_Date

java.util.Date m_Date
Current date


m_fInUse_SocketLocket

private static boolean m_fInUse_SocketLocket
Only for SocketLocket, do not use outside this function. Shared amoung ALL vvw net command senders

Constructor Detail

VVWNETCMDSENDER

public VVWNETCMDSENDER()
VVWNETCMDSENDER - Default, do not use


VVWNETCMDSENDER

public VVWNETCMDSENDER(SocketManager socketManager)
VVWNETCMDSENDER - Creates sender and keeps reference to socket manager

Parameters:
socketManager - SocketManager Share socket resource for multiple logical channels with only one physical pipe (XP socket limit problem)
Method Detail

SocketLocket

private boolean SocketLocket(boolean fCheck,
                             boolean fLock)
SocketLocket - Lock a socket for exclusive use

Parameters:
fCheck - boolean Do we want to acquire the lock, or just check if it is locked
fLock - boolean Are we locking, or unlocking the socket
Returns:
boolean true if locked

fInUse

boolean fInUse()
fInUse - Is the socket currently locked and in use

Returns:
boolean true if it is in use

LockSocket

boolean LockSocket()
LockSocket - Lock the socket for exclusive use

Returns:
boolean true if it is in use

UnLockSocket

boolean UnLockSocket()
UnLockSocket - Unlock the socket, allow others access

Returns:
boolean true if it is in use

setChannel

public void setChannel(long channel)
Sets the current channel in use by the applet

Parameters:
channel - long

getChannel

public long getChannel()
getChannel

Returns:
long

setTimeout

public void setTimeout(int nTimeout)
setTimeout for the low level socket

Parameters:
nTimeout - int

TryConnect

public boolean TryConnect(java.lang.String szIpAddress,
                          int dwPort)
Attempts to establish a connection to the specified server at the specified port.

Parameters:
szIpAddress - String IP address or 'look up-able' name
dwPort - int Normally 1234
Returns:
boolean true is connection succeeds

Disconnect

public void Disconnect(boolean fCloseAllInst)
Disconnects the connection established by socket

Parameters:
fCloseAllInst - boolean Normally false, just close the instance the caller opened. If true, the actual socket will close. This will leave other parts of the program with bad handles to the old socket.

BytesAvailable

private int BytesAvailable()
BytesAvailable - number of bytes available in the input data stream

Returns:
int

SendVvwCmd

public boolean SendVvwCmd(long lChannel,
                          MEDIACMD mCmd)
This sends a MediaCmd command to any channel in the VVW we are connected to/

Parameters:
lChannel - long The target channel 0..n
mCmd - MEDIACMD The MedaiCmd to send
Returns:
boolean true if the send is successful and returned

SendVvwCmd

public boolean SendVvwCmd(MEDIACMD mCmd)
Sends a command to the current channel

Parameters:
mCmd - MEDIACMD
Returns:
boolean

IsConnected

public boolean IsConnected()
IsConnected - Are we currently connected through the socket

Returns:
boolean true is we are connected

IsValid

public boolean IsValid()
IsValid - Is our connection currently valid

Returns:
boolean true if it is valid

IsReady

public boolean IsReady()
IsReady - Is our connection ready to receive commands

Returns:
boolean true if it is

StreamErrors

public int StreamErrors()
StreamErrors - Total stream errors since we first instantiated

Returns:
int Number of errors

IsFirstConnect

public boolean IsFirstConnect()
IsFirstConnect - Is this the first time we have connected to this machine, or are we going to reuse a currently connected socket.

Returns:
boolean true is we are not connected