public static byte[] transferObjectToByteArray(TransferObject to) { // out byte[] toByteArray = to.getByteData(); byte[] sendData = null; // if compress flag is true if (to.isCompress()) { sendData = TransferUtil.getOutputByCompress(toByteArray); } else { sendData = TransferUtil.getOutputByNormal(toByteArray); } //set long connection flag if (to.isLongConnection()) { sendData[0] |= TransferObject.LONGCONNECTION_FLAG; } //set new version flag if (to.isNewVersion()) { sendData[0] |= TransferObject.NEWVERSION_FLAG; } byte[] newData = new byte[sendData.Length + TatalaFlag.Length]; Array.Copy(TatalaFlag, 0, newData, 0, TatalaFlag.Length); Array.Copy(sendData, 0, newData, TatalaFlag.Length, sendData.Length); sendData = newData; return(sendData); }
/** * This method handles all outgoing and incoming data. * @param to TransferObject * @return Object */ public Object execute(TransferObject to) { if (to.isLongConnection()) { Monitor.Enter(theLock); try { if (longClientSession == null) { longClientSession = new LongClientSession(hostIp, hostPort, timeout, retryCount); } return(longClientSession.start(to)); } finally { Monitor.Exit(theLock); } } else { if (shortClientSession == null) { shortClientSession = new ShortClientSession(hostIp, hostPort, timeout, retryCount); } return(shortClientSession.start(to)); } }