public final class NetConnection extends AbstractNetConnection implements INetConnection
NetConnection
- implementation of the INetConnection
interface.INetConnection.Configuration
INetConnection.IListener, INetConnection.ListenerAdapter
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 and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
INetStream |
createNetStream()
Creates
INetStream instance. |
ISharedObject |
createSharedObject(java.lang.String name,
boolean persistent)
Creates
ISharedObject instance. |
java.lang.String |
farID()
Returns the identifier of the Flash Media Server instance to which this Flash Player or Adobe AIR instance is connected.
|
java.lang.String |
farNonce()
A value chosen substantially by Flash Media Server, unique to this connection.
|
ProtocolLayerInfo |
getInfo()
Returns connection info (read/written bytes/packets).
|
int |
getUploadBufferSize()
Returns upload buffer size.
|
int |
maxPeerConnections()
Returns total number of inbound and outbound peer connections that this instance allows.
|
void |
maxPeerConnections(int connections)
Sets total number of inbound and outbound peer connections that this instance allows.
|
java.lang.String |
nearID()
Returns the identifier of this Flash Player or Adobe AIR instance for this NetConnection instance.
|
java.lang.String |
nearNonce()
A value chosen substantially by this Flash Player or Adobe AIR instance, unique to this connection.
|
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
INetConnection.Configuration.SWF_HASH and INetConnection.Configuration.SWF_SIZE values using
swf file. |
java.util.List<? extends INetStream> |
unconnectedPeerStreams()
An object that holds all of the peer subscriber NetStream objects that are not associated with publishing NetStream objects.
|
boolean |
usingTLS()
Indicates whether a secure connection was made using native
Transport Layer Security (TLS) rather than HTTPS.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addEventListener, client, client, configuration, objectEncoding, objectEncoding, proxyType, proxyType, removeEventListener, uri
public NetConnection()
public NetConnection(java.util.Map<java.lang.String,java.lang.Object> configuration)
configuration
- connection configurationpublic NetConnection(java.util.Map<java.lang.String,java.lang.Object> configuration, java.util.concurrent.ExecutorService dispatcher, java.util.concurrent.ScheduledExecutorService scheduler)
configuration
- connection configurationdispatcher
- dispatcherscheduler
- schedulerpublic static void setSwfFileSizeAndHash(java.util.Map<java.lang.String,java.lang.Object> configuration, java.io.File swf) throws java.lang.Exception
INetConnection.Configuration.SWF_HASH
and INetConnection.Configuration.SWF_SIZE
values using
swf
file.configuration
- swf
- SWF filejava.lang.Exception
- if an exception occurredpublic void addHeader(java.lang.String operation, boolean mustUnderstand, java.lang.Object param)
INetConnection
addHeader
in interface INetConnection
operation
- identifies the header and the object data associated with itmustUnderstand
- (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 objectpublic void call(java.lang.String command, Responder responder, java.lang.Object... args)
INetConnection
call
in interface INetConnection
command
- commandresponder
- an optional object that is used to handle return values from the serverargs
- command argumentspublic void close()
INetConnection
close
in interface INetConnection
public void connect(java.lang.String url, java.lang.Object... args)
INetConnection
connect
in interface INetConnection
url
- url to connectargs
- connection argumentspublic boolean connected()
INetConnection
connected
in interface INetConnection
true
if connected; false
otherwisepublic java.lang.String connectedProxyType()
INetConnection
connectedProxyType
in interface INetConnection
public boolean usingTLS()
INetConnection
usingTLS
in interface INetConnection
public java.lang.String farID()
INetConnection
public java.lang.String farNonce()
INetConnection
public int maxPeerConnections()
INetConnection
public void maxPeerConnections(int connections)
INetConnection
public java.lang.String nearID()
INetConnection
public java.lang.String nearNonce()
INetConnection
public java.util.List<? extends INetStream> unconnectedPeerStreams()
INetConnection
public INetStream createNetStream()
INetConnection
INetStream
instance.createNetStream
in interface INetConnection
INetStream
instancepublic ISharedObject createSharedObject(java.lang.String name, boolean persistent)
INetConnection
ISharedObject
instance.createSharedObject
in interface INetConnection
name
- shared object namepersistent
- persistent flagISharedObject
instancepublic ProtocolLayerInfo getInfo()
INetConnection
getInfo
in interface INetConnection
public int getUploadBufferSize()
INetConnection
getUploadBufferSize
in interface INetConnection
public void setMaxUploadBandwidth(int bandwidth)
INetConnection
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.
setMaxUploadBandwidth
in interface INetConnection
bandwidth
- max upload bandwidthpublic void onBWDone()
public void onBWDone(java.lang.Object... args)
args
- arguments