public static byte[] GetBuffer(string _src) { byte[] strbyte = Encoding.UTF8.GetBytes(_src); byte[] lenbyte = BufferBase.GetBuffer((short)strbyte.Length); byte[] ret = new byte[strbyte.Length + lenbyte.Length]; lenbyte.CopyTo(ret, 0); if (strbyte.Length > 0) { strbyte.CopyTo(ret, lenbyte.Length); } return(ret); }
public byte[] GetByte(SocketDataHeadType pType, int pSrc) { byte[] ret = null; switch (pType) { case SocketDataHeadType.type_short: ret = BufferBase.GetBuffer((short)pSrc); break; case SocketDataHeadType.type_ushort: ret = BufferBase.GetBuffer((ushort)pSrc); break; case SocketDataHeadType.type_int: ret = BufferBase.GetBuffer((int)pSrc); break; default: DLog.LogErrorFormat("SocketData GetByte -> Type error : {0}", pType); break; } return(ret); }
public byte[] ReadBytes(int count) { byte[] ret = BufferBase.SReadBytes(Data, mIndex, count); mIndex += count; return(ret); }
public void AddInt(int _src) { AddBytes(BufferBase.GetBuffer(_src)); }
public void AddShort(short _src) { AddBytes(BufferBase.GetBuffer(_src)); }
public void AddString(string _src) { AddBytes(BufferBase.GetBuffer(_src)); }
public void AddBool(bool _src) { AddByte(BufferBase.GetBuffer(_src)); }
public void AddFloat(float _src) { AddBytes(BufferBase.GetBuffer(_src)); }
public void AddLong(long _src) { AddBytes(BufferBase.GetBuffer(_src)); }