예제 #1
0
 public byte[] ToBytes(short msgType, BaseNetworkMessage packet)
 {
     lock (m_Writer)
     {
         m_Writer.StartMessage(msgType);
         packet.Serialize(m_Writer);
         m_Writer.FinishMessage();
         byte[]      buf     = m_Writer.ToArray();
         List <byte> listbuf = new List <byte>();
         listbuf.AddRange(Write(PACKAGE_HEADER_ID));
         listbuf.AddRange(Write((ushort)buf.Length));
         listbuf.AddRange(buf);
         byte[] nesent = listbuf.ToArray();
         if (NetConfig.logFilter >= LogFilter.Developer)
         {
             Log.Debug("Write:" + BitConverter.ToString(nesent));
         }
         return(nesent);
     }
 }
예제 #2
0
 public void Write(BaseNetworkMessage msg)
 {
     msg.Serialize(this);
 }