📄 reference.txt
字号:
public static final String STRING String type identifier constant public static final String BOOLEAN Boolean type identifier constant Methods public Wrapper ( ) createw a wrapper containing NULL public Wrapper ( valueX ) the constructor of Wrapper, accepts double, boolean, string, hashmap, arraylist as parameters, if it receives no parameter, then wrapped type will be null. public class WrapperList wraps an ArrayList of wrapper objects Methods public WrapperList ( ) creates an empty wrapperlist public WrapperList ( Wrapper itemX ) creates a wrapperlist with itemX a first element public WrapperList ( List < Wrapper > sourceX ) creates a wrapperlist containing sourceX public void add ( ) adds a wrapped null to the list public void add ( String stringX ) adds a wrapped string to the list public void add ( double doubleX ) adds a wrapped double to the list public void add ( boolean booleanX ) adds a wrapped boolean to the list public void add ( WrapperMap mapX ) adds a wrapped wrappermap to the list public void add ( WrapperList listX ) adds a wrapped wrapperlist to the list public String getType ( int indexX ) returns the type of the specific element public String getString ( int indexX ) returns the string value of the specific element public double getDouble ( int indexX ) returns the double value of the specific element public boolean getBoolean ( int indexX ) returns the boolean value of the specific element public WrapperMap getMap ( int indexX ) returns the wrappermap value of the specific element public WrapperList getList ( int indexX ) returns the wrapperlist value of the specific element public class WrapperMap wraps a HashMap of wrapper objects Methods public WrapperMap ( ) creates an empty wrappermap public WrapperMap ( Map < String , Wrapper > sourceX ) creates a wrappermap containing the given map public WrapperMap ( String [ ] keysX , Object [ ] valuesX ) creates a wrappermap with the given key-value pairs public void put ( String keyX ) puts a null value in WrapperMap with the given key public void put ( String keyX , String stringX ) puts a String value in map under key public void put ( String keyX , double doubleX ) puts a double value in map under key public void put ( String keyX , boolean booleanX ) puts a boolean value in map under key public void put ( String keyX , WrapperMap mapX ) puts a map value in map under key public void put ( String keyX , WrapperList listX ) puts a list value in map under key public String getType ( String keyX ) returns type of the stored wrapper under key public String getString ( String keyX ) return string value of the wrapper at key public double getDouble ( String keyX ) returns double value of the wrapper at key public boolean getBoolean ( String keyX ) returns boolean value of the wrapper at key public WrapperMap getMap ( String keyX ) returns map value of the wrapper at key public WrapperList getList ( String keyX ) returns list value of the wrapper at key 3.6 InvokeEvent InvokeEvent is an event information holder for invoke calls. It is dispatched by client instances. To watch for invoke events, first you have to create an instance of the EventListener class, and redefine its onEvent function where you define what to do with the event, then you have to add this eventlistener instance to a client by calling Client.addInvokeEventListener. Properties public String id identifier of the call, this is what you pass on the client side with NetConnection.call( identifier ... ) public Client client the client instance where this event is coming from public WrapperList arguments the arguments related to this call 3.7 Stream Events StreamEvent is an event information holder for stream events. It is dispatched by client instances To watch for stream events, first you have to create an instance of the EventListener class, and redefine its onEvent function where you define what to do with the event, then you have to add this eventlistener instance to a client by calling Client.addStreamEventListener. Properties public Client client the client instance where this event is coming from public Stream stream the stream instance related to this stream. you may check the type of the instance first with Stream.type, then the name with Stream.name, then you have to enable or disable this request with Stream.enable( ) or Stream.disable( ). you can event store the stream instance, and enable/disable it later, the stream will be in idle state till that, and wont transfer any data. 3.8 Status Events StatusEvent is an event information holder for client's status or stream events. It is dispatched by client instances To watch for status events, first you have to create an instance of the EventListener class, and redefine its onEvent function where you define what to do with the event, then you have to add this eventlistener instance to a client by calling Client.addStatusEventListener. Properties public String code the code word for the actual event public Client client the client instance where this event is coming from public WrapperMap info the information map related to the event Static Properties public static final String FAILURE connection failure event code word container. public static final String CLOSURE connection closure event code word container public static final String SUCCESS connection success event code word container. the info property of the event may contain additional information about the success in the "application" key public static final String REJECTION connection rejection event code word container. the info property of the event may contain additional information about the rejection in the "application" key public static final String PLAYSTART stream play reset notify public static final String PLAYRESET stream play start notify public static final String PLAYFAILED stream play failed notify public static final String PUBLISHSTART stream publish start notify public static final String RECORDNOACCESS stream publish failed notify public static final String UNPUBLISHSUCCESS stream unpublish notify 3.9 Utilities Timer - com.milgra.server.api.Timer Simple timer. You have to define an EventListener first, then instantiate the timer with an arbitray interval in milliseconds, and the eventlistener. Example: LogWriter - com.milgra.server.util.LogWriter Log writer. Instantiate it with the log file name, then call addLog( String log ) to add new entry. Close it with close( ). Example:4. Extra Documentation 4.1 How to create a Custom Application? Donwload and unzip Milenia Grafter Server. Download and install the latest Eclipse for you platform. Ensure that you have JRE 1.5 or higher on your system, and JRE executables are in the execution path. Start Eclipse. File menuitem -> New -> Project, select Java project, click Next, type your desired project name as project name. If JRE 1.5 is not the default, select it under JRE. Click next. For default output folder, type YourProjectName/bin , so Eclipse will compile classes under a separate "bin" directory, and it will be easier for us to pack our classes into jar. Click on libraries tab, click Add External JARs, choose Milenia Grafter's folder, and select milenia.jar, click Open. That's all for project setup, click Finish. YourProjectName project appeared in Package Explorer. File menuitem -> New -> Class.For class name, type Application ( first letter uppercase ), and in the package field, type application ( all lowercase ). Every main custom application class must be application.Application. Click finish. The class is created. Every main application class must implement Milenia Grafter's IApplication interface. So, under package name type "import com.milgra.server.IApplication;" Now you have to create the four implemented functions: onEnter, onLeave, onStart, onClose, and add wanted functionality. If Eclipse shows no compiler errors/warnings, you are ready to pack your application into jar. Open a terminal, go in your Eclipse workspace directory, go under YourProject/bin. You see an "application" directory, where eclipse compiled our application classes. Type jar -cf yourappname.jar application And a yourappname.jar file appears in the directory. Copy this file under Milenia Grafter Server/applications. Start the server if it's not running, or load the application with MilGraAdmin under applications tab. ( refresh - load ). The application is ready to use. Check ut the sources of MilGraUnit, everything is there you want to use in your app deployment. 4.2 How to embed Milenia in my application package? You can easily embed the server in your package, simply set Library values to your hearts content, then instantiate the server, like its in Server class main function. There is also a shutdown hook in Server class, called shutdown, it kills the server and cleans up everything. 4.3 How to recompile Milenia? It's very simple. If you are using Eclipse, it places the compiled classes under bin folder, and to make a jar from Milenia, you simply have to go to bin folder, and type "jar -cmf manifest.txt milgra.jar bin" from the command line, and of course manifest.txt has to be there also, and it's ready.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -