コード例 #1
0
ファイル: HotlineObject.cs プロジェクト: Rampant-ai/Senesco
      public byte[] GetBytes()
      {
         if (m_id == null)
         {
            s_log.ErrorFormat("Object has null Object ID! ({0})", this.GetType().ToString());
            return null;
         }

         // First get the byte array for each object.
         // We don't mash them together just yet so we can calculate the overall length first.
         List<byte[]> byteArrays = new List<byte[]>();
         if (ObjectDataList != null)
         {
            foreach (IHotlineObjectData objData in ObjectDataList)
               byteArrays.Add(objData.GetBytes());
         }

         // Now smash all the objects together in the correct order.
         List<byte> byteList = new List<byte>();

         // First add the ObjectId as a Short.
         byteList.AddRange(m_id.GetBytes());

         // Next add the object data length as a Short.
         Short Length = new Short(DataUtils.TotalBytes(byteArrays));
         byteList.AddRange(Length.GetBytes());

         // Finally, the object data itself.
         foreach (byte[] byteArray in byteArrays)
            byteList.AddRange(byteArray);

         // Return the final list as an array.
         return byteList.ToArray();
      }
コード例 #2
0
ファイル: UserListEntry.cs プロジェクト: Rampant-ai/Senesco
      public UserListEntry(int socket, int icon, int status, string nick)
      {
         Socket = new Short(socket);
         Icon = new Short(icon);
         Status = new Short(status);
         NickLength = new Short(nick.Length);
         Nick = new NormalString(nick);

         this.ObjectDataList.Add(Socket);
         this.ObjectDataList.Add(Icon);
         this.ObjectDataList.Add(Status);
         this.ObjectDataList.Add(NickLength);
         this.ObjectDataList.Add(Nick);
      }
コード例 #3
0
ファイル: UserListEntry.cs プロジェクト: Rampant-ai/Senesco
      internal override void ParseBytes(byte[] objectData)
      {
         int index = 0;

         int socket = DataUtils.ReadShort(objectData, ref index);
         int icon = DataUtils.ReadShort(objectData, ref index);
         int status = DataUtils.ReadShort(objectData, ref index);
         int nickLength = DataUtils.ReadShort(objectData, ref index);
         string nick = DataUtils.ReadString(objectData, ref index, nickLength);

         Socket = new Short(socket);
         Icon = new Short(icon);
         Status = new Short(status);
         NickLength = new Short(nickLength);
         Nick = new NormalString(nick);

         this.ObjectDataList.Add(Socket);
         this.ObjectDataList.Add(Icon);
         this.ObjectDataList.Add(Status);
         this.ObjectDataList.Add(NickLength);
         this.ObjectDataList.Add(Nick);
      }
コード例 #4
0
ファイル: Transaction.cs プロジェクト: Rampant-ai/Senesco
      public void Configure(bool reply, int id, int errorCode)
      {
         Id = new Short(id);
         m_errorCode = new Long(errorCode);

         if (reply)
            m_class = new Short(1);
         else
            m_class = new Short(0);
      }
コード例 #5
0
ファイル: HotlineObject.cs プロジェクト: Rampant-ai/Senesco
 public HotlineObject()
 {
    int id = ObjectFactory.GetIdByType(this.GetType());
    m_id = new Short(id);
 }