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(); }
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); }
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); }
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); }
public HotlineObject() { int id = ObjectFactory.GetIdByType(this.GetType()); m_id = new Short(id); }