com.smaxe.me.uv.client
Class NetConnection

java.lang.Object
  extended by com.smaxe.me.uv.client.NetConnection

public final class NetConnection
extends java.lang.Object

NetConnection - Net Connection.

Version:
1.1.10
Author:
Andrei Sochirca
See Also:
JUV RTMP Client (J2ME edition)

Nested Class Summary
static class NetConnection.Configuration
          Configuration - NetConnection configuration constants.
static interface NetConnection.IListener
          IListener - NetConnection listener.
static class NetConnection.ListenerAdapter
          ListenerAdapter - NetConnection.IListener adapter.
 
Field Summary
static java.lang.String CALL_BADVERSION
          The URI specified in the NetConnection.connect method did not specify 'rtmp' as the protocol.
static java.lang.String CALL_FAILED
          The NetConnection.call method was not able to invoke the server-side method or command.
static java.lang.String CONNECT_APPSHUTDOWN
          The application has been shut down (for example, if the application is out of memory resources and must shut down to prevent the server from crashing) or the server has shut down.
static java.lang.String CONNECT_BANDWIDTH
          Connection bandwidth.
static java.lang.String CONNECT_CLOSED
          The connection was closed successfully
static java.lang.String CONNECT_FAILED
          The connection attempt failed.
static java.lang.String CONNECT_INVALID_APPLICATION
          The application name specified during connect is invalid.
static java.lang.String CONNECT_REJECTED
          The client does not have permission to connect to the application, the application expected different parameters from those that were passed, or the application name specified during the connection attempt was not found on the server.
static java.lang.String CONNECT_SUCCESS
          The connection attempt succeeded.
static ObjectEncoding defaultObjectEncoding
          Default object encoding.
static java.lang.String PROXY_TYPE_BEST
          PROXY_TYPE_BEST - "best"
static java.lang.String PROXY_TYPE_CONNECT
          PROXY_TYPE_CONNECT - "CONNECT"
static java.lang.String PROXY_TYPE_HTTP
          PROXY_TYPE_HTTP - "HTTP"
static java.lang.String PROXY_TYPE_NONE
          PROXY_TYPE_NONE - "none"
 
Constructor Summary
NetConnection()
          Constructor.
NetConnection(java.util.Hashtable configuration)
          Constructor.
NetConnection(java.util.Hashtable configuration, ExecutorService dispatcher)
          Constructor.
 
Method Summary
 void addEventListener(NetConnection.IListener listener)
          Registers an event listener.
 void addHeader(java.lang.String operation, boolean mustUnderstand, java.lang.Object param)
          Adds a context header to the AMF packet structure.
 void call(java.lang.String command, Responder responder, java.lang.Object[] args)
          Invokes a command or method on the server, or on an application server, to which the application instance is connected.
static java.util.Hashtable checkConfiguration(java.util.Hashtable configuration)
          Checks configuration and returns the configuration to use.
 java.lang.Object client()
          Returns the object on which callback methods should be invoked.
 void client(java.lang.Object client)
          Sets the object on which callback methods should be invoked.
 void close()
          Closes the connection.
 java.util.Hashtable configuration()
          Returns NetConnection configuration.
 void connect(java.lang.String url, java.lang.Object[] args)
          Opens a connection to a server.
 boolean connected()
          Checks if it is connected to the server.
 java.lang.String connectedProxyType()
          If a successful connection is made, indicates the method that was used to make it: a direct connection, the CONNECT method, or HTTP tunneling.
static java.util.Hashtable createDefaultConfiguration()
          Creates default configuration.
 ProtocolLayerInfo getInfo()
          Returns connection info (read/written bytes/packets).
 int getUploadBufferSize()
          Returns upload buffer size.
 ObjectEncoding objectEncoding()
          Returns object encoding.
 void objectEncoding(ObjectEncoding encoding)
          The object encoding (AMF version).
 java.lang.String proxyType()
          Returns proxy type.
 void proxyType(java.lang.String type)
          Determines whether native SSL is used for RTMPS instead of HTTPS, and whether the CONNECT method of tunneling is used to connect through a proxy server.
 void removeEventListener(NetConnection.IListener listener)
          Removes the listener.
 void setMaxUploadBandwidth(int bandwidth)
          Sets max upload bandwidth (in bytes per second).
 java.lang.String uri()
          The URI of the application server that was passed to INetConnection#connect(String, Object[]), if INetConnection#connect(String, Object[]) was used to connect to a server.
 boolean usingTLS()
          Indicates whether a secure connection was made using native Transport Layer Security (TLS) rather than HTTPS.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROXY_TYPE_NONE

public static final java.lang.String PROXY_TYPE_NONE
PROXY_TYPE_NONE - "none"

See Also:
Constant Field Values

PROXY_TYPE_HTTP

public static final java.lang.String PROXY_TYPE_HTTP
PROXY_TYPE_HTTP - "HTTP"

See Also:
Constant Field Values

PROXY_TYPE_CONNECT

public static final java.lang.String PROXY_TYPE_CONNECT
PROXY_TYPE_CONNECT - "CONNECT"

See Also:
Constant Field Values

PROXY_TYPE_BEST

public static final java.lang.String PROXY_TYPE_BEST
PROXY_TYPE_BEST - "best"

See Also:
Constant Field Values

CALL_FAILED

public static final java.lang.String CALL_FAILED
The NetConnection.call method was not able to invoke the server-side method or command.

See Also:
Constant Field Values

CALL_BADVERSION

public static final java.lang.String CALL_BADVERSION
The URI specified in the NetConnection.connect method did not specify 'rtmp' as the protocol. 'rtmp' must be specified when connecting to FMS and Red5. Either not supported version of AMF was used (3 when only 0 is supported)

See Also:
Constant Field Values

CONNECT_APPSHUTDOWN

public static final java.lang.String CONNECT_APPSHUTDOWN
The application has been shut down (for example, if the application is out of memory resources and must shut down to prevent the server from crashing) or the server has shut down.

See Also:
Constant Field Values

CONNECT_CLOSED

public static final java.lang.String CONNECT_CLOSED
The connection was closed successfully

See Also:
Constant Field Values

CONNECT_FAILED

public static final java.lang.String CONNECT_FAILED
The connection attempt failed.

See Also:
Constant Field Values

CONNECT_REJECTED

public static final java.lang.String CONNECT_REJECTED
The client does not have permission to connect to the application, the application expected different parameters from those that were passed, or the application name specified during the connection attempt was not found on the server.

See Also:
Constant Field Values

CONNECT_SUCCESS

public static final java.lang.String CONNECT_SUCCESS
The connection attempt succeeded.

See Also:
Constant Field Values

CONNECT_INVALID_APPLICATION

public static final java.lang.String CONNECT_INVALID_APPLICATION
The application name specified during connect is invalid.

See Also:
Constant Field Values

CONNECT_BANDWIDTH

public static final java.lang.String CONNECT_BANDWIDTH
Connection bandwidth.

Note:
This event is introduced in the JUV RTMP Client library and not available in ActionScript/FMS interaction.

See Also:
Constant Field Values

defaultObjectEncoding

public static ObjectEncoding defaultObjectEncoding
Default object encoding.

Constructor Detail

NetConnection

public NetConnection()
Constructor.


NetConnection

public NetConnection(java.util.Hashtable configuration)
Constructor.

Parameters:
configuration - connection configuration

NetConnection

public NetConnection(java.util.Hashtable configuration,
                     ExecutorService dispatcher)
Constructor.

Parameters:
configuration - connection configuration
dispatcher - dispatcher
Method Detail

createDefaultConfiguration

public static java.util.Hashtable createDefaultConfiguration()
Creates default configuration.

Returns:
default configuration

checkConfiguration

public static java.util.Hashtable checkConfiguration(java.util.Hashtable configuration)
Checks configuration and returns the configuration to use.

Parameters:
configuration -
Returns:
configuration

client

public void client(java.lang.Object client)
Sets the object on which callback methods should be invoked.

Parameters:
client - the object on which callback methods should be invoked

client

public java.lang.Object client()
Returns the object on which callback methods should be invoked.

Returns:
the object on which callback methods should be invoked

connected

public boolean connected()
Checks if it is connected to the server. 'Connected' means that the connection is accepted by the server ("NetConnection.Connect.Success" response is received on 'connect' request), rather than a 'physical' connection is established.

Returns:
true if connected; false otherwise

connectedProxyType

public java.lang.String connectedProxyType()
If a successful connection is made, indicates the method that was used to make it: a direct connection, the CONNECT method, or HTTP tunneling.

Returns:
connection proxy type

objectEncoding

public ObjectEncoding objectEncoding()
Returns object encoding.

Returns:
object encoding

objectEncoding

public void objectEncoding(ObjectEncoding encoding)
The object encoding (AMF version).

Parameters:
encoding - object encoding

proxyType

public java.lang.String proxyType()
Returns proxy type.

Returns:
proxy type

proxyType

public void proxyType(java.lang.String type)
Determines whether native SSL is used for RTMPS instead of HTTPS, and whether the CONNECT method of tunneling is used to connect through a proxy server.

Parameters:
type - proxy type

uri

public java.lang.String uri()
The URI of the application server that was passed to INetConnection#connect(String, Object[]), if INetConnection#connect(String, Object[]) was used to connect to a server.

Returns:
uri application server uri

usingTLS

public boolean usingTLS()
Indicates whether a secure connection was made using native Transport Layer Security (TLS) rather than HTTPS.

Returns:
TLS?

addHeader

public void addHeader(java.lang.String operation,
                      boolean mustUnderstand,
                      java.lang.Object param)
Adds a context header to the AMF packet structure. This header is sent with every future AMF packet.

Parameters:
operation - identifies the header and the object data associated with it
mustUnderstand - (default = false) — A value of true indicates that the server must understand and process this header before it handles any of the following headers or messages.
param - (default = null) — any object

call

public void call(java.lang.String command,
                 Responder responder,
                 java.lang.Object[] args)
Invokes a command or method on the server, or on an application server, to which the application instance is connected. You must create a server-side function to pass to this method.

Parameters:
command - command
responder - an optional object that is used to handle return values from the server
args - command arguments

connect

public void connect(java.lang.String url,
                    java.lang.Object[] args)
Opens a connection to a server. Through this connection, you can play back audio or video (FLV) files from an HTTP address or from the local file system, or you can invoke commands on a remote server.

Parameters:
url - url to connect
args - connection arguments

close

public void close()
Closes the connection.


addEventListener

public void addEventListener(NetConnection.IListener listener)
Registers an event listener.

Parameters:
listener - listener to add

removeEventListener

public void removeEventListener(NetConnection.IListener listener)
Removes the listener.

Parameters:
listener - listener to remove

configuration

public final java.util.Hashtable configuration()
Returns NetConnection configuration. Check NetConnection.Configuration class constants for configuration properties.

Returns:
configuration

getInfo

public ProtocolLayerInfo getInfo()
Returns connection info (read/written bytes/packets).

Returns:
overall connection info

getUploadBufferSize

public int getUploadBufferSize()
Returns upload buffer size.

Returns:
upload buffer size

setMaxUploadBandwidth

public void setMaxUploadBandwidth(int bandwidth)
Sets max upload bandwidth (in bytes per second).

Note:
- you can change max upload bandwidth after connection is established only if NetConnection.Configuration.MAX_UPLOAD_BANDWIDTH configuration property was set positive before connection is established.

Parameters:
bandwidth - max upload bandwidth