📄 reference.txt
字号:
Constructor public Client ( IApplication applicationX ) You can create a new remote client instance with the constrcutor, attached to the given application. After creation, you can connect the client to a remote server, and exchange data , pull / push streams. Getter/Setters public long getId ( ) Returns the unique identifier number of the client. public long getPing( ) The ping rountrip time of the client. public long getBytesIn( ) The received byte count by the server from this client public long getBytesOut( ) The sent byte count to this client public double getBandIn( ) The actual incoming bandwidth of the client in bytes per second. public double getBandOut( ) The actual outgoing bandwidth of the client in bytes per second. public String getIp( ) Returns the ip address of the client. public String getAgent( ) The player / server info of the client. public String getReferrer( ) The referrer of the client. Passive mode only methods : public void accept ( ) Accepts the client public void accept ( Wrapper wrapperX ) Accepts the client with a wrapper as acception info, the client receives it as the NetStatus event's info.applicaiton parameter public void reject ( Wrapper wrapperX ) Rejects the client, you can pass a wrapper as rejection info, the client receives it as the NetStatus event's info.application parameter public void detach ( ) Detaches the client from the server Active mode only methods : public void connect ( String uriX , Wrapper argumentsX ) Connects the client to a remote server with address uriX, passing argumentX as connection object public void connect ( String uriX , WrapperList argumentsX ) Connects the client to a remote server with address uriX, passing argumentsX as connection object Common Methods public void call ( String invokeID ) Invokes a method on client side without arguments public void call ( String invokeID , Wrapper argumentX ) Invokes a method on client side with a wrapper as arguments public void call ( String invokeID , WrapperList argumentX ) Invokes a method on client side with an wrapperlist as argument public void callResult ( String invokeID , Wrapper argumentX ) If a responder for a specific function is defined on client side, you may pass back a result with this function public void callResult ( String invokeID , WrapperList argumentsX ) If a responder for a specific function is defined on client side, you may pass back a result with this function with a wrapperlist as an arguments public void addStreamEventListener ( EventListener listenerX ) You may add a stream event listener object to the client with this method. public void addInvokeEventListener ( EventListener listenerX ) You may add an invoke event listener object to the client with this method. public void addStatusEventListener ( EventListener listenerX ) You may add a status event listener object to the client with this method. public HashMap < Double , String > getPlayers ( ) Returns the list of streams played by the client public HashMap < Double , String >getRouters ( ) Returns the list of streams published by the client 3.4 Stream class - com.milgra.server.api.stream Stream class contains stream related properties and methods. There are two types of stream on Milenia : incoming streams, which is published by clients or other servers, and outgoing streams, which are played by clients or pulled by other server. Incoming streams are represented by stream routers, outgoing streams by stream players. Both of them are represented by the stream class. However if stream instance is a stream player, you can only enable/disable/delete it, other methods aren't working on it. Mileania's stream pool is shared, so every applicaiton can reach every stream published to the server. You can publihs/record/play streams from clients without access control by default. If you want to control stream access, you have to define a stream event listener in your custom application, and register it with addStreamEventListener( ). After this you will be notified about every NetStream.play and NetStream.publish event, and you have to enable or disable these requests. Properties public static final String PLAYER; player type identifier public static final String ROUTER; router type identifier public String type; type of the stream, can be PLAYER or ROUTER public String name; name of the played/routed stream. router names are unique, but multiple players can have the same name, when they are playing the same stream. public String mode; if type is router, then recording mode. can be live, record, append public Client client; owner of the stream, if stream has no owner, then null Methods public Stream ( String nameX ) creates a stream on local server under the given name public Stream ( String nameX , Client clientX ) creates a stream on remote server defined by clientX. public void play ( String nameX ) starts playing the given stream. if given stream doesn't exist, it waits for its appereance. If stream name ends with ".flv", it tries to play a recorded stream with that name from the default stream directory. public void publish ( String nameX , String modeX ) publishes the given stream to the remote server, if stream is an active stream, with the given mode. public void delete ( ) deletes the stream from the server, if its a live stream, its broadcasting is stopped public void enable ( ) enables a stream route/play request. if you have defined a stream event listener for a client, you have to enable/disable streams related to incoming events public void disable ( ) disables a stream route/play request, the client will receive a NetStream.Publish.Failed or NetStream.Play.Failed event. if you have defined a stream event listener for a client, you have to enabled/disable streams related to incoming events. public void enableAudio ( boolean stateX ) enables/disables audio transfer in the specific stream public void enableVideo ( boolean stateX ) enables/disables video transfer in the specific streams public void pause ( boolean stateX ) pauses/resumes stream playing public void record ( boolean stateX ) starts/stops recording the specific streams public void seek ( int positionX ) seeks in vod stream public void speed ( double multiplierX ) sets speed of vod stream public double getSpeed ( ) returns the speed of the vod player public double getPosition ( ) returns position of vod public double getDuration ( ) returns duration of stream public String getType ( ) returns type of stream public String getName ( ) returns name of stream public String getMode ( ) returns mode of stream Static Methods public static ArrayList < String > getStreamNames ( ) returns streams avaliable on server 3.5 Wrapper classes Wrapper classes are a simple value wrappers, but most of your time programming Milenia Grafter Server you will use wrappers. As you know, java is a strictly typed language and actionscript is weakly typed. During data exchange flash can send objects and arrays containing mixed data types, and on the java side after deserialization we have to keep this state somehow in the strictly typed environment. That's why Wrapper class was born. AMF deserializer wraps data in Wrapper objects, and serializer uses Wrappers for input also. public class Wrapper wraps a java data type Properties public String type contains the type of the wrapped value public double doubleValue the value of a wrapped double public String stringValue the value of a wrapped string public boolean booleanValue the value of a wrapped boolean public WrapperMap mapValue the value of a wrapped WrapperMap public WrapperList listValue the value of a wrapped WrapperList Static properties public static final String MAP HashMap type identifier constant public static final String NULL Null type identifier constant public static final String LIST ArrayList type identifier constant public static final String DOUBLE Double type identifier constant
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -