zoukankan      html  css  js  c++  java
  • Setting up flash chat application using project Darkstar

    转自:http://siddhantt.com/Blog/?p=20

    i) Download PDS server from and extract it to any suitable location. (** EDIT ** use 0.9.8 version as flash client is not compatible with the latest darkstar server *** EDIT end**).

    ii) Set up SGS_HOME environment variable.

    This will be the location of the extracted folder from earlier step which contains folder bin , lib.

    Suppose you downloaded the server to c: and extracted it there only , then SGS_HOME should be  c:\sgs-server-dist-0.9.9\sgs-server-dist-0.9.8.

    For setting up environment variable in windows use .

    iii) Make a folder (any name).This folder will contain files for deploying the PDS application. In this article we will call this folder appfolder . Inside the appfolder , make a folder with name deploy. This will be the place where all the jars related to our PDS app will be placed.

    In the folder we need to put three files.

    a) myapp.boot
    b) myapp.properties
    c) logging.properties

    Sample myapp.boot

    SGS_DEPLOY=F:/tut/appfolder/deploy

    SGS_PROPERTIES=F:/tut/appfolder/myapp.properties

    SGS_LOGGING=F:/tut/appfolder/logging.properties

    File explanation.

    The SGS_DEPLOY should point to the deploy folder path which is “Full path of appfolder”/deploy in our case.
    SGS_PROPERTIES will be the path to myapp.properties file in the appfolder.
    SGS_LOGGING will be the path to logging.properties file in the appfolder.

    Sample myapp.properties

    com.sun.sgs.app.name=AppManager
    com.sun.sgs.app.root=F:/tut/appfolder/data/AppManager
    com.sun.sgs.app.port=1139
    com.sun.sgs.app.listener=AppManager

    All of the fields are self explanatory.

    logging.properties file can be same as $SGS_HOME/tutorial/conf/logging.properties.

    Now we need to develop our PDS application.

    Our PDS application will consist of two files AppManager.java (http://siddhantt.com/Blog/files/AppManager.java) , GameSessionListener.java ( http://siddhantt.com/Blog/files/GameSessionListener.java). To get the understanding of these two files go through the tutorial document shipped along with the server.

    Now we need to Build the PDS application. We will use eclipse IDE for building the PDS application. Steps to follow :-

    a) In eclipse make a new project (give any name to it.)

    b) In the src folder of the project make new file AppManager.java. Content of this file should be same as that of http://siddhantt.com/Blog/files/AppManager.java

    c) Make one more file GameSessionListener.java which should be same as http://siddhantt.com/Blog/files/GameSessionListener.java

    d) Now add jar file sgs-server-api-0.9.9.jar found in the SGS_HOME lib folder , to the java build path. For adding jar file , right click on the project in eclipse , click on java build path (in the left pane of the open popup) , click on the Add External Jars (in the right pane) and select the jar file.

    e) Make folder META-INF in the src folder of the project. Inside META-INF folder make empty file app.properties.

    The project should build without any issues. We need to now export the jar file of the project in the deploy folder of the application folder. For exporting jar , do the following steps :-

    a) Right Click on the project in eclipse and select export.
    b) In the window pop up select Jar File under java folder.
    c) Click next and give the path of jar file (for e.g. F:/tut/appfolder/deploy/tut.jar

    Now to run this PDS application open the command prompt and type

    (for windows ) java -jar %SGS_HOME%/bin/sgs-boot.jar F:/tut/appfolder/myapp.boot

    Your PDS application should run smoothly.

    Now comes the setting up of client part. For the client , API that we will be using are http://code.google.com/p/darkstar-as3/.

    But these API still dont work with v 0.9.9. So in order to run this tutorial one needs to get the earlier tutorial running with darkstar v 0.9.8 (which will involved setting up different SGS_HOME , building source with different SGS jar and deleting the Appmanager directory in the data folder of the appfolder).

    For starting the tutorial download the zip file www.siddhantt.com/Blog/files/flash_client.zip. Extract it in a folder . 

    In the extracted folder the com folder belongs to the darkstar-as3 client API . If you want to use the latest version of darkstar-as3 , just replace the com folder in the extracted folder with your dakrstar-as3 version.

    For running the chat following must be done before :-

    i) Run the sgs server from previous tutorial.
    ii) Run the flash socket file server. Running socket file server is necessary if you want flash client to make socket connection to your server.  More information can be found here.

         For setting up the socket file server on windows , following steps are to be taken :-

             a) Download  files from here and extract it in a folder.
             b) Install python and and add python exe path folder to the system path.
             c) Go to the folder where standalone python script is there (flashpolicyd_v0.6\Standalone folder in the extracted folder from a step) and type  python flashpolicyd.py –file=../flashpolicy.xml –port=843.  This should setup the socket file server.

    In case you are getting exceptions in the PDS console window while running the chat window , do update the java files of the earlier tutorial and run the PDS again.

    Third part , which comprises of explanation of the code of earlier tutorials is still not complete but will be up soon.

  • 相关阅读:
    php中的短标签 太坑人了
    <转>让SVN用户能够修改自身密码的PHP页面
    配置Apache2 管理 SVN
    <转>Java 理论与实践: 正确使用 Volatile 变量
    <转>java中静态方法和非静态方法的存储
    分享:将业务系统页面嵌入到统一平台中(简易版)
    权限管理系统之字典(代码)管理
    权限管理系统之模块管理
    权限管理系统之用户管理
    轻松搞定Struts 2:三步走上手小入门
  • 原文地址:https://www.cnblogs.com/sevenyuan/p/1610604.html
Copyright © 2011-2022 走看看