示例#1
0
        public static TransferObject byteArrayToTransferObject(byte[] byteArray)
        {
            //TransferObject to = new TransferObject();
            int receiveLength = byteArray.Length;

            byte[] toByteArray = new byte[receiveLength - 1];
            Array.Copy(byteArray, 1, toByteArray, 0, receiveLength - 1);
            byte flagbyte = byteArray[0];

            TransferObject to = null;

            //check if new version of transfer object
            if (TransferUtil.isNewVersion(flagbyte))
            {
                to = new NewTransferObject();
            }
            else
            {
                to = new StandardTransferObject();
            }

            if (TransferUtil.isCompress(flagbyte))
            {
                toByteArray = TransferUtil.getInputByCompress(toByteArray);
            }
            else
            {
                toByteArray = TransferUtil.getInputByNormal(toByteArray);
            }
            to.setByteData(toByteArray);

            return(to);
        }
示例#2
0
        public void Logout()
        {
            NewTransferObject to = transferObjectFactory.createNewTransferObject();

            to.setCalleeMethod(LongClientSession.METHOD_CLOSE);
            to.registerReturnType(TransferObject.DATATYPE_VOID);
            ServerExecutor.execute(to);
        }
示例#3
0
        public void doSomething()
        {
            NewTransferObject to = transferObjectFactory.createNewTransferObject();

            to.setCalleeClass("com.qileyuan.tatala.example.proxy.NewToServerProxy");
            to.setCalleeMethod("doSomething");
            to.registerReturnType(TransferObject.DATATYPE_VOID);
            ServerExecutor.execute(to);
        }
示例#4
0
        public void ExitLobby(int userID)
        {
            NewTransferObject to = transferObjectFactory.createNewTransferObject();

            to.setCalleeMethod(ExecuteClientCallMethodName);
            to.putString("exitLobby"); //callee method
            to.putInt(userID);
            to.registerReturnType(TransferObject.DATATYPE_VOID);
            ServerExecutor.execute(to);
        }
示例#5
0
        public void SendMovement(int userID, float[] target)
        {
            NewTransferObject to = transferObjectFactory.createNewTransferObject();

            to.setCalleeMethod(ExecuteClientCallMethodName);
            to.putString("receiveMovement"); //callee method
            to.putInt(userID);
            to.putFloatArray(target);
            to.registerReturnType(TransferObject.DATATYPE_VOID);
            ServerExecutor.execute(to);
        }
示例#6
0
        public void SendMessage(int userID, string message)
        {
            NewTransferObject to = transferObjectFactory.createNewTransferObject();

            to.setCalleeMethod(ExecuteClientCallMethodName);
            to.putString("receiveMessage"); //callee method
            to.putInt(userID);
            to.putString(message);
            to.registerReturnType(TransferObject.DATATYPE_VOID);
            ServerExecutor.execute(to);
        }
示例#7
0
        public void EnterLobby(int userID, string userName, int userLevel, int equipedWeaponTypeId, float[] position)
        {
            NewTransferObject to = transferObjectFactory.createNewTransferObject();

            to.setCalleeMethod(ExecuteClientCallMethodName);
            to.putString("enterLobby"); //callee method
            to.putInt(userID);
            to.putString(userName);
            to.putInt(userLevel);
            to.putInt(equipedWeaponTypeId);
            to.putFloatArray(position);
            to.registerReturnType(TransferObject.DATATYPE_VOID);
            ServerExecutor.execute(to);
        }
示例#8
0
        public String sayHello(int Id, String name)
        {
            NewTransferObject to = transferObjectFactory.createNewTransferObject();

            to.setCalleeClass("com.qileyuan.tatala.example.proxy.NewToServerProxy");
            to.setCalleeMethod("sayHello");
            to.registerReturnType(TransferObject.DATATYPE_STRING);

            to.putInt(Id);
            to.putString(name);

            Object resultObj = ServerExecutor.execute(to);
            String result    = (String)resultObj;

            return(result);
        }
示例#9
0
        public String[] getArray(int[] intarr, String[] strarr)
        {
            NewTransferObject to = transferObjectFactory.createNewTransferObject();

            to.setCalleeClass("com.qileyuan.tatala.example.proxy.NewToServerProxy");
            to.setCalleeMethod("getArray");
            to.registerReturnType(TransferObject.DATATYPE_STRINGARRAY);

            to.putIntArray(intarr);
            to.putStringArray(strarr);

            Object resultObj = ServerExecutor.execute(to);

            String[] result = (String[])resultObj;

            return(result);
        }
示例#10
0
        public override Object execute(TransferObject baseto)
        {
            NewTransferObject to           = (NewTransferObject)baseto;
            string            calleeMethod = to.getCalleeMethod();

            if (calleeMethod.Equals("receiveMessage"))
            {
                int    playerId = to.getInt();
                string message  = to.getString();
                NetworkManager.Instance.ReceiveMessage(playerId, message);
            }
            else if (calleeMethod.Equals("addPlayer"))
            {
                int     playerId            = to.getInt();
                string  playerName          = to.getString();
                int     playerLevel         = to.getInt();
                int     equipedWeaponTypeId = to.getInt();
                float[] position            = to.getFloatArray();
                NetworkManager.Instance.AddPlayer(playerId, playerName, playerLevel, equipedWeaponTypeId, position);
            }
            else if (calleeMethod.Equals("receiveMovement"))
            {
                int     playerId = to.getInt();
                float[] target   = to.getFloatArray();
                NetworkManager.Instance.ReceiveMovement(playerId, target);
            }
            else if (calleeMethod.Equals("receivePlayerInfos"))
            {
                to.getInt(); //ignore userId
                int[]    playerIds            = to.getIntArray();
                string[] playerNames          = to.getStringArray();
                int[]    playerLevels         = to.getIntArray();
                int[]    equipedWeaponTypeIds = to.getIntArray();
                float[]  playerPositions      = to.getFloatArray();
                NetworkManager.Instance.ReceivePlayerInfos(playerIds, playerNames, playerLevels, equipedWeaponTypeIds, playerPositions);
            }
            else if (calleeMethod.Equals("removePlayer"))
            {
                int playerId = to.getInt();
                NetworkManager.Instance.RemovePlayer(playerId);
            }

            return(null);
        }