/// <summary> /// 写入字节流 /// </summary> /// <param name="aByte"></param> /// <param name="m_Response"></param> protected static void WriteByte(IGameResponse m_Response, byte aByte) { byte[] outputStream = new byte[1]; outputStream[0] = aByte; //m_Response.OutputStream.Write(outputStream, 0, outputStream.Length); m_Response.Write(outputStream); }
/// <summary> /// 内部输出Action的值 /// </summary> /// <returns>无</returns> protected void InternalWriteAction(IGameResponse response) { foreach (object obj in arrayList) { Type type = obj.GetType(); if (type == typeof(String)) { WriteString(response, Convert.ToString(obj)); } else if (type == typeof(double)) { WriteDouble(response, Convert.ToDouble(obj)); } else if (type == typeof(float)) { WriteFloat(response, Convert.ToSingle(obj)); } else if (type == typeof(Int64)) { WriteLong(response, Convert.ToInt64(obj)); } else if (type == typeof(Int32) || type.IsEnum) { WriteDWord(response, Convert.ToInt32(obj)); } else if (type == typeof(Int16)) { WriteWord(response, Convert.ToInt16(obj)); } else if (type == typeof(Byte)) { WriteByte(response, Convert.ToByte(obj)); } else if (type == typeof(bool)) { WriteBool(response, Convert.ToBoolean(obj)); } else if (type == typeof(DataStruct)) { DataStruct ds = ((DataStruct)obj); ds.WriteActionNum(response); ds.InternalWriteAction(response); } else if (type == typeof(byte[])) { //By Seamoon已序列化好的内容,直接写入 var bytes = (byte[])(obj); WriteDWord(response, bytes.Length); response.Write(bytes); } } }
/// <summary> /// 写入字节流 /// </summary> /// <param name="aValue"></param> /// <param name="response"></param> protected static void WriteWord(IGameResponse response, Int16 aValue) { byte[] outputStream = BitConverter.GetBytes(aValue); response.Write(outputStream); }
/// <summary> /// 写入字节流 /// </summary> /// <param name="aByte"></param> /// <param name="m_Response"></param> protected static void WriteByte(IGameResponse m_Response, byte aByte) { byte[] outputStream = new byte[1]; outputStream[0] = aByte; //m_Response.OutputStream.Write(outputStream, 0, outputStream.Length); m_Response.Write(outputStream); }
/// <summary> /// 写入字节流 /// </summary> /// <param name="aValue"></param> /// <param name="response"></param> protected static void WriteWord(IGameResponse response, Int16 aValue) { byte[] outputStream = BitConverter.GetBytes(aValue); response.Write(outputStream); }
/// <summary> /// /// </summary> /// <param name="response"></param> /// <param name="aValue"></param> protected static void WriteBool(IGameResponse response, Boolean aValue) { byte[] outputStream = BitConverter.GetBytes(aValue); response.Write(outputStream); }
/// <summary> /// /// </summary> /// <param name="response"></param> /// <param name="aValue"></param> protected static void WriteFloat(IGameResponse response, float aValue) { byte[] outputStream = BitConverter.GetBytes(aValue); response.Write(outputStream); }
/// <summary> /// 内部输出Action的值 /// </summary> /// <returns>无</returns> protected void InternalWriteAction(IGameResponse response) { foreach (object obj in arrayList) { Type type = obj.GetType(); if (type == typeof(String)) { WriteString(response, Convert.ToString(obj)); } else if (type == typeof(double)) { WriteDouble(response, Convert.ToDouble(obj)); } else if (type == typeof(float)) { WriteFloat(response, Convert.ToSingle(obj)); } else if (type == typeof(Int64)) { WriteLong(response, Convert.ToInt64(obj)); } else if (type == typeof(Int32) || type.IsEnum) { WriteDWord(response, Convert.ToInt32(obj)); } else if (type == typeof(Int16)) { WriteWord(response, Convert.ToInt16(obj)); } else if (type == typeof(Byte)) { WriteByte(response, Convert.ToByte(obj)); } else if (type == typeof(bool)) { WriteBool(response, Convert.ToBoolean(obj)); } else if (type == typeof(DataStruct)) { DataStruct ds = ((DataStruct)obj); ds.WriteActionNum(response); ds.InternalWriteAction(response); } else if (type == typeof(byte[])) { //By Seamoon已序列化好的内容,直接写入 var bytes = (byte[])(obj); WriteDWord(response, bytes.Length); response.Write(bytes); } } }
/// <summary> /// /// </summary> /// <param name="response"></param> /// <param name="aValue"></param> protected static void WriteFloat(IGameResponse response, float aValue) { byte[] outputStream = BitConverter.GetBytes(aValue); response.Write(outputStream); }
/// <summary> /// /// </summary> /// <param name="response"></param> /// <param name="aValue"></param> protected static void WriteDouble(IGameResponse response, double aValue) { byte[] outputStream = BitConverter.GetBytes(aValue); response.Write(outputStream); }