Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="response"></param>
        /// <param name="value"></param>
        protected static void WriteDateTime(BaseGameResponse response, DateTime value)
        {
            long ts = (value.ToDateTime() - MathUtils.UnixEpochDateTime).TotalSeconds.ToLong();

            byte[] outputStream = BitConverter.GetBytes(ts);
            response.Write(outputStream);
        }
Exemple #2
0
 /// <summary>
 /// 写入字节流
 /// </summary>
 /// <param name="aByte"></param>
 /// <param name="response"></param>
 protected static void WriteByte(BaseGameResponse response, byte aByte)
 {
     byte[] outputStream = new byte[1];
     outputStream[0] = aByte;
     //m_Response.OutputStream.Write(outputStream, 0, outputStream.Length);
     response.Write(outputStream);
 }
Exemple #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="response"></param>
 protected void JsonWriteResponse(BaseGameResponse response)
 {
     if (!IsNotRespond)
     {
         var message = BuildJsonPack();
         response.Write(encoding.GetBytes(message));
     }
     WriteEnd();
 }
Exemple #4
0
 /// <summary>
 /// 内部输出Action的值
 /// </summary>
 /// <returns>无</returns>
 protected void InternalWriteAction(BaseGameResponse 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);
         }
     }
 }
Exemple #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="response"></param>
        public override void WriteResponse(BaseGameResponse response)
        {
            var message = BuildResponsePack();

            response.Write(encoding.GetBytes(message));
        }
Exemple #6
0
 /// <summary>
 /// 写入字节流
 /// </summary>
 /// <param name="aByte"></param>
 /// <param name="response"></param>
 protected static void WriteByte(BaseGameResponse response, byte aByte)
 {
     byte[] outputStream = new byte[1];
     outputStream[0] = aByte;
     //m_Response.OutputStream.Write(outputStream, 0, outputStream.Length);
     response.Write(outputStream);
 }
Exemple #7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="response"></param>
 /// <param name="value"></param>
 protected static void WriteDateTime(BaseGameResponse response, DateTime value)
 {
     long ts = (value.ToUniversalTime() - MathUtils.UnixEpochDateTime).TotalSeconds.ToLong();
     byte[] outputStream = BitConverter.GetBytes(ts);
     response.Write(outputStream);
 }
Exemple #8
0
 /// <summary>
 /// 写入字节流
 /// </summary>
 /// <param name="aValue"></param>
 /// <param name="response"></param>
 protected static void WriteUShort(BaseGameResponse response, UInt16 aValue)
 {
     byte[] outputStream = BitConverter.GetBytes(aValue);
     response.Write(outputStream);
 }
Exemple #9
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="response"></param>
 /// <param name="aValue"></param>
 protected static void WriteLong(BaseGameResponse response, Int64 aValue)
 {
     byte[] outputStream = BitConverter.GetBytes(aValue);
     response.Write(outputStream);
 }
Exemple #10
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="response"></param>
 /// <param name="aValue"></param>
 protected static void WriteBool(BaseGameResponse response, Boolean aValue)
 {
     byte[] outputStream = BitConverter.GetBytes(aValue);
     response.Write(outputStream);
 }
Exemple #11
0
 /// <summary>
 /// 内部输出Action的值
 /// </summary>
 /// <returns>无</returns>
 protected void InternalWriteAction(BaseGameResponse 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)
         {
             WriteInt(response, Convert.ToInt32(obj));
         }
         else if (type == typeof(Int16))
         {
             WriteShort(response, Convert.ToInt16(obj));
         }
         else if (type == typeof(UInt64))
         {
             WriteULong(response, Convert.ToUInt64(obj));
         }
         else if (type == typeof(UInt32))
         {
             WriteUInt(response, Convert.ToUInt32(obj));
         }
         else if (type == typeof(UInt16))
         {
             WriteUShort(response, Convert.ToUInt16(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(DateTime))
         {
             WriteDateTime(response, Convert.ToDateTime(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);
             WriteInt(response, bytes.Length);
             response.Write(bytes);
         }
     }
 }
Exemple #12
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="response"></param>
 protected void JsonWriteResponse(BaseGameResponse response)
 {
     if (!IsNotRespond)
     {
         var message = BuildJsonPack();
         response.Write(encoding.GetBytes(message));
     }
     WriteEnd();
 }
Exemple #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="response"></param>
 /// <param name="value"></param>
 protected static void WriteDateTime(BaseGameResponse response, DateTime value)
 {
     byte[] outputStream = BitConverter.GetBytes(value.Ticks);
     response.Write(outputStream);
 }
Exemple #14
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="response"></param>
 /// <param name="value"></param>
 protected static void WriteDateTime(BaseGameResponse response, DateTime value)
 {
     byte[] outputStream = BitConverter.GetBytes(value.Ticks);
     response.Write(outputStream);
 }
Exemple #15
0
 /// <summary>
 /// 写入字节流
 /// </summary>
 /// <param name="aValue"></param>
 /// <param name="response"></param>
 protected static void WriteUShort(BaseGameResponse response, UInt16 aValue)
 {
     byte[] outputStream = BitConverter.GetBytes(aValue);
     response.Write(outputStream);
 }
Exemple #16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="response"></param>
 /// <param name="aValue"></param>
 protected static void WriteLong(BaseGameResponse response, Int64 aValue)
 {
     byte[] outputStream = BitConverter.GetBytes(aValue);
     response.Write(outputStream);
 }
Exemple #17
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="response"></param>
 /// <param name="aValue"></param>
 protected static void WriteBool(BaseGameResponse response, Boolean aValue)
 {
     byte[] outputStream = BitConverter.GetBytes(aValue);
     response.Write(outputStream);
 }