lundi 9 janvier 2017

I need help about an GameServer on Java or Php [on hold]

The As3 Code is

from com.pandaland.events.GameServerEvent.as public class GameServerEvent extends Event {

    public static const ON_CONNECT:String = "ON_CONNECT";
    public static const ON_CLOSE:String = "ON_CLOSE";
    public static const LOGIN:String = "cs_login";
    public static const DISCONNECT:String = "cs_disconnect";
    public static const JOIN_ROOM:String = "cs_joinRoom";
    public static const MOVE_AVATAR:String = "cs_moveAvatar";
    public static const SET_AVATAR:String = "cs_setAvatar";
    public static const UNSET_AVATAR:String = "cs_unsetAvatar";
    public static const CHAT_MSG:String = "cs_chatMsg";
    public static const EMOTE_MSG:String = "cs_emoteMsg";
    public static const ADD_ITEM:String = "EVENT_ADD_ITEM";
    public static const THROW:String = "EVENT_THROW";
    public static const DO_ACTION:String = "EVENT_ACTION";
    public static const JOIN_GAME:String = "EVENT_JOIN_GAME";
    public static const JOIN_HOME:String = "JOIN_HOME";
    public static const ADD_BUDDY:String = "ADD_BUDDY";
    public static const UPDATE_PLAYERINFO:String = "UPDATE_PLAYERINFO";
    public static const UPDATE_USERPLAYERINFO:String = "UPDATE_USERPLAYERINFO";
    public static const RECEIVE_ECARD:String = "RECEIVE_ECARD";
    public static const LOGOUT_SUCCESS:String = "LOGOUT_SUCCESS";
    public static const RECEIVE_ONLINEPLAYERS:String = "RECEIVE_ONLINEPLAYERS";

    private var m_arrPars:Array;

    public function GameServerEvent(tValue:String, tArray:Array=null)
    {
        super(tValue);
        this.m_arrPars = tArray;
    }

    override public function toString():String
    {
        return ((("[Instance of com.pandaland.events.ServerEvent][Pars:" + this.m_arrPars.join(",")) + "]"));
    }

    public function get pars():Array
    {
        return (this.m_arrPars);
    }


}

from com/pandaland/util/sockets/ConnectionService.as

    public static const TOTAL_CMD_DISPATCH:int = 2;
    public static const PAR_DELIMETER:String = ";";
    public static const SRV_CMD_DELIMETER:String = "|";
    public static const CMD_LOGIN:int = 0;
    public static const CMD_LOGOUT:int = 2;
    public static const CMD_MOVE:int = 20;
    public static const CMD_JOIN_GAME:int = 11;
    public static const CMD_QUIT_GAME:int = 16;
    public static const CMD_JOIN_HOME:int = 26;
    public static const CMD_JOIN_ROOM:int = 25;
    public static const CMD_UPDATE_PLAYER:int = 35;
    public static const CMD_NOTIFY_UPDATE_PLAYER:int = 37;
    public static const CMD_CHAT:int = 40;
    public static const CMD_EMOTE:int = 41;
    public static const CMD_SEND_ECARD:int = 42;
    public static const CMD_ACTION:int = 50;
    public static const CMD_ADDBUDDY:int = 60;
    public static const CMD_GETROOMINFO:int = 70;
    public static const CMD_GET_ONLINEPLAYERS:int = 500;
    private static var instance:ConnectionService;

    private var m_strIncomingMsgBuffer:String;
    private var m_arrEventBuffer:Array;
    private var m_arrCmds:Array;
    private var m_eventDispatchTimer:Timer;

    public function ConnectionService()
    {
        var tService:ConnectionService;
        super();
        tService = this;
        this.m_arrCmds = [];
        this.m_arrCmds[0] = GameServerEvent.LOGIN;
        this.m_arrCmds[2] = GameServerEvent.DISCONNECT;
        this.m_arrCmds[3] = GameServerEvent.LOGOUT_SUCCESS;
        this.m_arrCmds[10] = GameServerEvent.JOIN_ROOM;
        this.m_arrCmds[11] = GameServerEvent.JOIN_GAME;
        this.m_arrCmds[26] = GameServerEvent.JOIN_HOME;
        this.m_arrCmds[20] = GameServerEvent.MOVE_AVATAR;
        this.m_arrCmds[30] = GameServerEvent.SET_AVATAR;
        this.m_arrCmds[31] = GameServerEvent.UNSET_AVATAR;
        this.m_arrCmds[35] = GameServerEvent.UPDATE_PLAYERINFO;
        this.m_arrCmds[37] = GameServerEvent.UPDATE_USERPLAYERINFO;
        this.m_arrCmds[40] = GameServerEvent.CHAT_MSG;
        this.m_arrCmds[41] = GameServerEvent.EMOTE_MSG;
        this.m_arrCmds[42] = GameServerEvent.RECEIVE_ECARD;
        this.m_arrCmds[50] = GameServerEvent.DO_ACTION;
        this.m_arrCmds[60] = GameServerEvent.ADD_BUDDY;
        this.m_arrCmds[100] = GameServerEvent.ADD_ITEM;
        this.m_arrCmds[500] = GameServerEvent.RECEIVE_ONLINEPLAYERS;
        this.m_arrEventBuffer = [];
        this.m_eventDispatchTimer = new Timer(10);
        this.m_eventDispatchTimer.addEventListener(TimerEvent.TIMER, this.dispatchCmdQueueEvent);
    }

    public function sendCmd(nCmd:int, arrPars:Array=null):void
    {
        Logger.warn((((("send: " + nCmd) + "(") + arrPars) + ")"));
        if (super.connected == true)
        {
            if (arrPars == null) || (arrPars.length == 0)
            {
                super.writeln(nCmd + SRV_CMD_DELIMETER);
            }
            else
            {
                super.writeln((((nCmd + PAR_DELIMETER) + arrPars.join(PAR_DELIMETER)) + SRV_CMD_DELIMETER));
            };
        }
        else
        {
            this.dispatchEvent(new GameServerEvent(GameServerEvent.ON_CLOSE));
        };
    }

    override public function onReceiveMsg(strMsg:String):void
    {
        var arrMsg:Array;
        var nI:int;
        var strMsgPart:String;
        var arrPars:Array;
        var strFirstPar:String;
        var nCmdID:int;
        var tList:Array;
        var tMsg:String;
        var tEvent:GameServerEvent;
        Logger.warn("onReceiveMsg: " + strMsg);
        if (strMsg.charAt((strMsg.length - 1)) != SRV_CMD_DELIMETER)
        {
            this.m_strIncomingMsgBuffer = (this.m_strIncomingMsgBuffer + strMsg);
            return;
        };
        strMsg = (this.m_strIncomingMsgBuffer + strMsg);
        this.m_strIncomingMsgBuffer = "";
        arrMsg = strMsg.split(SRV_CMD_DELIMETER);
       nI = 0;
        while (nI < arrMsg.length)
        {
            strMsgPart = arrMsg[nI];
            arrPars = strMsgPart.split(PAR_DELIMETER);
            strFirstPar = arrPars.shift();
            if (!((isNaN(Number(strFirstPar))) || ((strFirstPar == ""))))
            {
                nCmdID = int(strFirstPar);
                tList = arrPars;
                if (this.m_arrCmds[nCmdID] != null)
                {
                    tMsg = this.m_arrCmds[nCmdID];
                    tEvent = new GameServerEvent(tMsg, tList);
                    if ((((this.m_arrEventBuffer.length == 0)) && (nI == 0)))
                    {
                        this.dispatchEvent(tEvent);
                    }
                    else
                    {
                        this.pushServerEvent(tEvent);
                    };
                }
                else
                {
                    throw (new IllegalOperationError("call undefined COMMAND ID: " + nCmdID));
                };
            };
            nI++;
        };
    }

from com/pandaland/util/sockets/CSocket.as

    private function send(strMsg:String):void
    {
        this.writeUTFBytes(strMsg);
        this.flush();
    }

   private function readResponse():void
    {
        var inst:CSocket;
        var strMsg:String;
        var fTimeHandler:Function;
        var t:Timer;
        inst = this;
        strMsg = inst.readUTFBytes(inst.bytesAvailable);
        if (this.m_nReceiveDelayMs == 0)
        {
            inst.onReceiveMsg(strMsg);
        }
        else
        {
            fTimeHandler = function (e:Event):void
            {
                inst.onReceiveMsg(strMsg);
            };
            t = new Timer(this.m_nReceiveDelayMs, 1);
            t.addEventListener("timer", fTimeHandler);
            t.start();
        };
    }

and i need help to make from this code to an Working GameServer can somebody help me on Java or Php i give you an exemplar how the flash client send it [AS3Flash-Client]send policy-file-request [RandomPhp-SERVER]revice xml answer from server this part works. [AS3Flash-Client]send 0;userid;loginsesssionkey;roomid| after this i never get an answer from server does somebody know why?.

Aucun commentaire:

Enregistrer un commentaire