com.smaxe.uv.client
Class NetConnection

java.lang.Object
  extended by AbstractNetConnection
      extended by com.smaxe.uv.client.NetConnection
All Implemented Interfaces:
INetConnection

public final class NetConnection
extends AbstractNetConnection
implements INetConnection

NetConnection - implementation of the INetConnection interface.

Version:
1.5.12
Author:
Andrei Sochirca
See Also:
JUV RTMP Client

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.smaxe.uv.client.INetConnection
INetConnection.Configuration, INetConnection.IListener, INetConnection.ListenerAdapter
 
Field Summary
 
Fields inherited from interface com.smaxe.uv.client.INetConnection
CALL_BADVERSION, CALL_FAILED, CONNECT_APPSHUTDOWN, CONNECT_BANDWIDTH, CONNECT_CLOSED, CONNECT_FAILED, CONNECT_INVALID_APPLICATION, CONNECT_REJECTED, CONNECT_SUCCESS, defaultObjectEncoding, PROXY_TYPE_BEST, PROXY_TYPE_CONNECT, PROXY_TYPE_HTTP, PROXY_TYPE_NONE
 
Constructor Summary
NetConnection()
          Constructor.
NetConnection(java.util.Map<java.lang.String,java.lang.Object> configuration)
          Constructor.
NetConnection(java.util.Map<java.lang.String,java.lang.Object> configuration, java.util.concurrent.ExecutorService dispatcher, java.util.concurrent.ScheduledExecutorService scheduler)
          Constructor.
 
Method Summary
 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.
 void close()
          Closes the connection.
 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.
 ProtocolLayerInfo getInfo()
          Returns connection info (read/written bytes/packets).
 int getUploadBufferSize()
          Returns upload buffer size.
 void onBWDone()
          'onBWDone' invoked by FMS server.
 void onBWDone(java.lang.Object... args)
          'onBWDone' invoked by FMS server.
 void setMaxUploadBandwidth(int bandwidth)
          Sets max upload bandwidth (in bytes per second).
static void setSwfFileSizeAndHash(java.util.Map<java.lang.String,java.lang.Object> configuration, java.io.File swf)
          Sets Configuration#SWF_HASH and Configuration#SWF_SIZE values using swf file.
 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
 
Methods inherited from interface com.smaxe.uv.client.INetConnection
addEventListener, client, client, configuration, objectEncoding, objectEncoding, proxyType, proxyType, removeEventListener, uri
 

Constructor Detail

NetConnection

public NetConnection()
Constructor.


NetConnection

public NetConnection(java.util.Map<java.lang.String,java.lang.Object> configuration)
Constructor.

Parameters:
configuration - connection configuration

NetConnection

public NetConnection(java.util.Map<java.lang.String,java.lang.Object> configuration,
                     java.util.concurrent.ExecutorService dispatcher,
                     java.util.concurrent.ScheduledExecutorService scheduler)
Constructor.

Parameters:
configuration - connection configuration
dispatcher - dispatcher
scheduler - scheduler
Method Detail

setSwfFileSizeAndHash

public static void setSwfFileSizeAndHash(java.util.Map<java.lang.String,java.lang.Object> configuration,
                                         java.io.File swf)
                                  throws java.lang.Exception
Sets Configuration#SWF_HASH and Configuration#SWF_SIZE values using swf file.

Parameters:
configuration -
swf - SWF file
Throws:
java.lang.Exception - if an exception occurred

addHeader

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

Specified by:
addHeader in interface INetConnection
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)
Description copied from interface: INetConnection
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.

Specified by:
call in interface INetConnection
Parameters:
command - command
responder - an optional object that is used to handle return values from the server
args - command arguments

close

public void close()
Description copied from interface: INetConnection
Closes the connection.

Specified by:
close in interface INetConnection

connect

public void connect(java.lang.String url,
                    java.lang.Object... args)
Description copied from interface: INetConnection
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.

Specified by:
connect in interface INetConnection
Parameters:
url - url to connect
args - connection arguments

connected

public boolean connected()
Description copied from interface: INetConnection
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.

Specified by:
connected in interface INetConnection
Returns:
true if connected; false otherwise

connectedProxyType

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

Specified by:
connectedProxyType in interface INetConnection
Returns:
connection proxy type

usingTLS

public boolean usingTLS()
Description copied from interface: INetConnection
Indicates whether a secure connection was made using native Transport Layer Security (TLS) rather than HTTPS.

Specified by:
usingTLS in interface INetConnection
Returns:
TLS?

getInfo

public ProtocolLayerInfo getInfo()
Description copied from interface: INetConnection
Returns connection info (read/written bytes/packets).

Specified by:
getInfo in interface INetConnection
Returns:
overall connection info

getUploadBufferSize

public int getUploadBufferSize()
Description copied from interface: INetConnection
Returns upload buffer size.

Specified by:
getUploadBufferSize in interface INetConnection
Returns:
upload buffer size

setMaxUploadBandwidth

public void setMaxUploadBandwidth(int bandwidth)
Description copied from interface: INetConnection
Sets max upload bandwidth (in bytes per second).

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

Specified by:
setMaxUploadBandwidth in interface INetConnection
Parameters:
bandwidth - max upload bandwidth

onBWDone

public void onBWDone()
'onBWDone' invoked by FMS server.


onBWDone

public void onBWDone(java.lang.Object... args)
'onBWDone' invoked by FMS server.

Parameters:
args - arguments