Esempio n. 1
0
        public override byte[] Serialize(Pointer p)
        {
            base.Serialize(p);

            BitPacker.AddInt(ref m_SerializeBuffer, p, (GameMessageKind));
            return(m_SerializeBuffer);
        }
Esempio n. 2
0
        public override byte[] Serialize(Pointer p)
        {
            base.Serialize(p);
            BitPacker.AddInt(ref m_SerializeBuffer, p, (int)Kind);

            if (TheGame == null)
            {
                BitPacker.AddBool(ref m_SerializeBuffer, p, false); // do not have game data
            }
            else
            {
                BitPacker.AddBool(ref m_SerializeBuffer, p, true); // have game data
                BitPacker.AddComponent(ref m_SerializeBuffer, p, TheGame, false);
            }

            BitPacker.AddBool(ref m_SerializeBuffer, p, TargetPlayer != null);
            if (TargetPlayer != null)
            {
                BitPacker.AddComponent(ref m_SerializeBuffer, p, TargetPlayer, false);
            }

            BitPacker.AddString(ref m_SerializeBuffer, p, TheGameID.ToString());

            return(m_SerializeBuffer);
        }
Esempio n. 3
0
        public override byte[] Serialize(Pointer p)
        {
            base.Serialize(p);
            BitPacker.AddBool(ref m_SerializeBuffer, p, IsRefresh);
            BitPacker.AddBool(ref m_SerializeBuffer, p, IsServerPacket);
            BitPacker.AddInt(ref m_SerializeBuffer, p, TheGames.Count);
            for (int i = 0; i < TheGames.Count; i++)
            {
                if (!IsRefresh)
                {
                    BitPacker.AddInt(ref m_SerializeBuffer, p, (int)Kinds[i]);
                }

                // determine if this packet goes to another server, in which case we need to send the full game data,
                // or to the client in which case we need to just send a matchInfo object
                BitPacker.AddComponent(ref m_SerializeBuffer, p, TheGames[i], IsServerPacket);

                BitPacker.AddBool(ref m_SerializeBuffer, p, TargetPlayers.Count > i);
                if (!IsRefresh && TargetPlayers[i] != null)
                {
                    BitPacker.AddComponent(ref m_SerializeBuffer, p, TargetPlayers[i], false);
                }
            }

            return(m_SerializeBuffer);
        }
Esempio n. 4
0
 public override void Serialize(ref byte[] buffer, Pointer p)
 {
     base.Serialize(ref buffer, p);
     BitPacker.AddInt(ref buffer, p, PhaseID);
     BitPacker.AddString(ref buffer, p, PhaseName);
     BitPacker.AddLong(ref buffer, p, ResponseTime);
 }
Esempio n. 5
0
        public override void Serialize(ref byte[] buffer, Pointer p)
        {
            BitPacker.AddInt(ref buffer, p, GamesPlayed);
            BitPacker.AddDouble(ref buffer, p, RatingMean);
            BitPacker.AddDouble(ref buffer, p, RatingStandardDeviation);

            base.Serialize(ref buffer, p);
        }
Esempio n. 6
0
        public override void Serialize(ref byte[] buffer, Pointer p, bool includeComponents)
        {
            BitPacker.AddPropertyBag(ref buffer, p, Properties);
            BitPacker.AddStatBag(ref buffer, p, Stats);
            BitPacker.AddInt(ref buffer, p, ID);

            base.Serialize(ref buffer, p, includeComponents);
        }
Esempio n. 7
0
 public override void SerializeValue(ref byte[] dat, Pointer p)
 {
     BitPacker.AddInt(ref dat, p, m_Value.Length);
     for (int i = 0; i < m_Value.Length; i++)
     {
         BitPacker.AddString(ref dat, p, Name);
         BitPacker.AddLong(ref dat, p, m_Value[i].Ticks);
     }
 }
Esempio n. 8
0
 public override byte[] Serialize(Pointer p)
 {
     base.Serialize(p);
     BitPacker.AddInt(ref m_SerializeBuffer, p, (int)LoginConnectionType);
     BitPacker.AddString(ref m_SerializeBuffer, p, AccountName);
     BitPacker.AddString(ref m_SerializeBuffer, p, Password);
     BitPacker.AddBool(ref m_SerializeBuffer, p, IsNewAccount);
     BitPacker.AddPropertyBag(ref m_SerializeBuffer, p, Parms);
     return(m_SerializeBuffer);
 }
Esempio n. 9
0
 public void Serialize(ref byte[] buffer, Pointer p)
 {
     BitPacker.AddInt(ref buffer, p, Configs.Count);
     Dictionary <string, string> .Enumerator enu = Configs.GetEnumerator();
     while (enu.MoveNext())
     {
         BitPacker.AddString(ref buffer, p, enu.Current.Key);
         BitPacker.AddString(ref buffer, p, enu.Current.Value);
     }
 }
Esempio n. 10
0
 public override byte[] Serialize(Pointer p)
 {
     base.Serialize(p);
     byte[] serverName = System.Text.Encoding.UTF8.GetBytes(ServerName);
     BitPacker.AddString(ref m_SerializeBuffer, p, ServerName);
     BitPacker.AddInt(ref m_SerializeBuffer, p, MaxPlayers);
     BitPacker.AddInt(ref m_SerializeBuffer, p, CurrentPlayers);
     BitPacker.AddString(ref m_SerializeBuffer, p, UserID);
     return(m_SerializeBuffer);
 }
 public override byte[] Serialize(Pointer p)
 {
     base.Serialize(p);
     BitPacker.AddInt(ref m_SerializeBuffer, p, Characters.Count);
     for (int i = 0; i < Characters.Count; i++)
     {
         BitPacker.AddComponent(ref m_SerializeBuffer, p, Characters[i]);
     }
     return(m_SerializeBuffer);
 }
 public override byte[] Serialize(Pointer p)
 {
     base.Serialize(p);
     BitPacker.AddString(ref m_SerializeBuffer, p, m_ServerVersion.ToString());
     BitPacker.AddBytes(ref m_SerializeBuffer, p, m_PublicRSAKey);
     BitPacker.AddInt(ref m_SerializeBuffer, p, m_ConnectionKeySize);
     BitPacker.AddString(ref m_SerializeBuffer, p, ServerName);
     BitPacker.AddInt(ref m_SerializeBuffer, p, MaxPlayers);
     BitPacker.AddInt(ref m_SerializeBuffer, p, CurrentPlayers);
     return(m_SerializeBuffer);
 }
Esempio n. 13
0
 public override byte[] Serialize(Pointer p)
 {
     base.Serialize(p);
     BitPacker.AddString(ref m_SerializeBuffer, p, AuthTicket.ToString());
     BitPacker.AddString(ref m_SerializeBuffer, p, ServerName);
     BitPacker.AddString(ref m_SerializeBuffer, p, ServerIP);
     BitPacker.AddInt(ref m_SerializeBuffer, p, ServerPort);
     BitPacker.AddString(ref m_SerializeBuffer, p, TargetResource.ToString());
     BitPacker.AddBool(ref m_SerializeBuffer, p, IsAssistedTransfer);
     return(m_SerializeBuffer);
 }
Esempio n. 14
0
        public override byte[] Serialize(Pointer p)
        {
            base.Serialize(p);

            BitPacker.AddInt(ref m_SerializeBuffer, p, Characters.Count);
            for (int i = 0; i < Characters.Count; i++)
            {
                // this is just an overview packet.  don't send component details.
                BitPacker.AddComponent(ref m_SerializeBuffer, p, Characters[i], false);
            }
            return(m_SerializeBuffer);
        }
Esempio n. 15
0
 public override byte[] Serialize(Pointer p)
 {
     base.Serialize(p);
     BitPacker.AddBool(ref m_SerializeBuffer, p, Remove);
     BitPacker.AddString(ref m_SerializeBuffer, p, PropertyBagId.ToString());
     BitPacker.AddInt(ref m_SerializeBuffer, p, Properties.Length);
     for (int i = 0; i < Properties.Length; i++)
     {
         BitPacker.AddProperty(ref m_SerializeBuffer, p, Properties[i]);
     }
     return(m_SerializeBuffer);
 }
Esempio n. 16
0
 public void Serialize(ref byte[] buffer, Pointer p)
 {
     BitPacker.AddBool(ref buffer, p, IsEnabled);
     BitPacker.AddLong(ref buffer, p, SampleInterval.Ticks);
     BitPacker.AddString(ref buffer, p, Category);
     BitPacker.AddString(ref buffer, p, CounterName);
     BitPacker.AddString(ref buffer, p, InstanceName);
     BitPacker.AddString(ref buffer, p, HelpText);
     BitPacker.AddInt(ref buffer, p, History.Count);
     for (int i = 0; i < History.Count; i++)
     {
         BitPacker.AddSingle(ref buffer, p, History[i].Value);
         BitPacker.AddLong(ref buffer, p, History[i].Timestamp.Ticks);
     }
 }
Esempio n. 17
0
        public void Serialize(ref byte[] buffer, Pointer p)
        {
            BitPacker.AddLong(ref buffer, p, LastLogin.Ticks);
            BitPacker.AddLong(ref buffer, p, UserSince.Ticks);
            BitPacker.AddLong(ref buffer, p, LastPasswordChange.Ticks);

            BitPacker.AddString(ref buffer, p, ID.ToString());

            BitPacker.AddString(ref buffer, p, Email);
            BitPacker.AddString(ref buffer, p, Username);

            BitPacker.AddBool(ref buffer, p, IsLocked);
            BitPacker.AddBool(ref buffer, p, IsOnline);
            BitPacker.AddBool(ref buffer, p, IsApproved);

            BitPacker.AddStringList(ref buffer, p, Roles);

            BitPacker.AddInt(ref buffer, p, ServiceNotes.Count);
            for (int i = 0; i < ServiceNotes.Count; i++)
            {
                ServiceLogEntry sle = ServiceNotes[i];
                BitPacker.AddString(ref buffer, p, sle.EntryBy);
                BitPacker.AddString(ref buffer, p, sle.Note);
                BitPacker.AddString(ref buffer, p, sle.EntryType);
                BitPacker.AddInt(ref buffer, p, sle.CharacterId);
                BitPacker.AddLong(ref buffer, p, sle.TimeStampUTC.Ticks);
            }

            BitPacker.AddPropertyBag(ref buffer, p, AddedProperties);

            BitPacker.AddInt(ref buffer, p, LoginSessions.Count);
            for (int i = 0; i < LoginSessions.Count; i++)
            {
                AccountProfile.Session s = LoginSessions[i];
                BitPacker.AddLong(ref buffer, p, s.LoginUTC.Ticks);
                BitPacker.AddLong(ref buffer, p, s.LogoutUTC.Ticks);
                BitPacker.AddString(ref buffer, p, s.IP);
            }

            BitPacker.AddLong(ref buffer, p, CurrentLoginTime.Ticks);

            BitPacker.AddInt(ref buffer, p, Characters.Count);
            for (int i = 0; i < Characters.Count; i++)
            {
                ICharacterInfo ci = Characters[i];
                BitPacker.AddComponent(ref buffer, p, ci);
            }
        }
Esempio n. 18
0
        public void Serialize(ref byte[] buffer, Pointer p)
        {
            BitPacker.AddBool(ref buffer, p, AllowRemoteConnections);
            BitPacker.AddInt(ref buffer, p, TotalUserCount);
            BitPacker.AddString(ref buffer, p, UserDataStore);
            BitPacker.AddInt(ref buffer, p, Users.Count);

            foreach (User su in Users)
            {
                BitPacker.AddString(ref buffer, p, su.Username);
                BitPacker.AddStringList(ref buffer, p, new List <string>(su.Roles));
                BitPacker.AddBool(ref buffer, p, su.IsLocked);
                BitPacker.AddString(ref buffer, p, su.ID.ToString());
                BitPacker.AddString(ref buffer, p, su.Email);
                BitPacker.AddLong(ref buffer, p, su.LastLogin.Ticks);
            }
        }
Esempio n. 19
0
 /// <summary>
 /// Serializes the component to binary
 /// </summary>
 /// <param name="buffer"></param>
 /// <param name="p"></param>
 /// <param name="includeSubComponents"></param>
 public virtual void Serialize(ref byte[] buffer, Pointer p, bool includeSubComponents)
 {
     //Log.LogMsg("Serializing component " + GetType().ToString() + " as ID " + TypeHash.ToString());
     if (!includeSubComponents)
     {
         return;
     }
     lock (m_Components)
     {
         //List<Component> wisps = m_Components.FindAll(w => w is ISerializableWispObject);
         BitPacker.AddInt(ref buffer, p, m_Components.Count);
         for (int i = 0; i < m_Components.Count; i++)
         {
             IComponent wisp = m_Components[i] as IComponent;
             BitPacker.AddUInt(ref buffer, p, wisp.TypeHash);
             wisp.Serialize(ref buffer, p, includeSubComponents);
         }
     }
 }
Esempio n. 20
0
        public override byte[] Serialize(Pointer p)
        {
            base.Serialize(p);

            BitPacker.AddInt(ref m_SerializeBuffer, p, (int)ReplyCode);
            BitPacker.AddInt(ref m_SerializeBuffer, p, ReplyPacketID);
            BitPacker.AddString(ref m_SerializeBuffer, p, ReplyMessage);
            BitPacker.AddInt(ref m_SerializeBuffer, p, ReplyPacketType);
            BitPacker.AddInt(ref m_SerializeBuffer, p, ReplyPacketSubType);

            bool hasParms = Parms.PropertyCount > 0;

            BitPacker.AddBool(ref m_SerializeBuffer, p, hasParms);
            if (hasParms)
            {
                BitPacker.AddPropertyBag(ref m_SerializeBuffer, p, Parms);
            }
            return(m_SerializeBuffer);
        }
Esempio n. 21
0
        public virtual void Serialize(ref byte[] buffer, Pointer p)
        {
#if !IS_CLIENT
            BitPacker.AddString(ref buffer, p, CurrentSessionID.ToString());
            BitPacker.AddString(ref buffer, p, Username);
#endif
            BitPacker.AddInt(ref buffer, p, MaxCharacters);

            // Add roles
            BitPacker.AddInt(ref buffer, p, UserRoles.Length);
            for (int i = 0; i < UserRoles.Length; i++)
            {
                BitPacker.AddString(ref buffer, p, UserRoles[i]);
            }

#if !IS_CLIENT
            // Login IPs
            BitPacker.AddInt(ref buffer, p, LoginHistoryIP.Count);
            for (int i = 0; i < LoginHistoryIP.Count; i++)
            {
                BitPacker.AddString(ref buffer, p, LoginHistoryIP.ElementAt(i));
            }

            // Login Times
            BitPacker.AddInt(ref buffer, p, LoginHistoryTime.Count);
            for (int i = 0; i < LoginHistoryTime.Count; i++)
            {
                BitPacker.AddLong(ref buffer, p, LoginHistoryTime.ElementAt(i).Ticks);
            }

            // Logout Times
            BitPacker.AddInt(ref buffer, p, LogoffHistoryTime.Count);
            for (int i = 0; i < LogoffHistoryTime.Count; i++)
            {
                BitPacker.AddLong(ref buffer, p, LogoffHistoryTime.ElementAt(i).Ticks);
            }

            BitPacker.AddString(ref buffer, p, m_CurrentSessionID.ToString());
            BitPacker.AddLong(ref buffer, p, m_CurrentLoginTime.Ticks);
            BitPacker.AddString(ref buffer, p, m_CurrentIP);
#endif
        }
Esempio n. 22
0
        public override void Serialize(ref byte[] buffer, Pointer p, bool includeSubComponents)
        {
            // General match info
            BitPacker.AddInt(ref buffer, p, Owner);
            BitPacker.AddString(ref buffer, p, GameID.ToString());
            BitPacker.AddPropertyBag(ref buffer, p, Properties);

            // Players
            List <ICharacterInfo> players = AllPlayers;

            BitPacker.AddInt(ref buffer, p, players.Count);
            for (int i = 0; i < players.Count; i++)
            {
                ICharacterInfo ci = players[i];
                BitPacker.AddPropertyBag(ref buffer, p, ci.Properties);
                BitPacker.AddStatBag(ref buffer, p, ci.Stats);
                BitPacker.AddInt(ref buffer, p, ci.ID);
            }

            base.Serialize(ref buffer, p, includeSubComponents);
        }
Esempio n. 23
0
        public virtual void Serialize(ref byte[] buffer, Pointer p)
        {
            BitPacker.AddInt(ref buffer, p, Scripts.AttachedScripts.Count);
            foreach (GameObjectScript s in Scripts.AttachedScripts.Values)
            {
                BitPacker.AddUInt(ref buffer, p, s.TypeHash);
            }

            BitPacker.AddInt(ref buffer, p, Effects.AttachedEffects.Count);
            foreach (Effect e in Effects.AttachedEffects.Values)
            {
                BitPacker.AddUInt(ref buffer, p, e.Information.EffectKind);
                e.Serialize(ref buffer, p);
            }

            BitPacker.AddDouble(ref buffer, p, PhysicalState.Position.X);
            BitPacker.AddDouble(ref buffer, p, PhysicalState.Position.Y);
            BitPacker.AddDouble(ref buffer, p, PhysicalState.Position.Z);

            BitPacker.AddDouble(ref buffer, p, PhysicalState.Rotation.X);
            BitPacker.AddDouble(ref buffer, p, PhysicalState.Rotation.Y);
            BitPacker.AddDouble(ref buffer, p, PhysicalState.Rotation.Z);
        }
Esempio n. 24
0
 public override void SerializeValue(ref byte[] dat, Pointer p)
 {
     BitPacker.AddString(ref dat, p, Name);
     BitPacker.AddInt(ref dat, p, m_Value);
 }
Esempio n. 25
0
 public override void Serialize(ref byte[] buffer, Pointer p)
 {
     base.Serialize(ref buffer, p);
     BitPacker.AddInt(ref buffer, p, Version);
 }
Esempio n. 26
0
        /*/ ENVELOPE (never encrypted) - always 10 bytes long
         * /// =========================
         * /// Int64 message length
         * /// BOOL IsHeaderEncrypted
         * /// byte HeaderLength
         * ///
         * /// HEADER (if encrypted, then it's always encrypted with the "connection" key,)
         * /// ==========
         * /// Int64 BodyLength (Body) in bytes - anything longer than Int32.MaxValue will need to be sent via stream
         * /// Int32 PacketType
         * /// BYTE PacketFlags (IsBodyEncrypted, IsP2PTransmission, IsCompressed)
         * /// string EndpointID
         *
         * /// BODY (if encrypted, then it's always encrypted with the EndpointID's key)
         * /// ==========
         * // byte[] data */

        /// <summary>
        /// Returns a binary representation of this packet suitable for transmission across the wire.  Override this method to control the
        /// serialization process.  The byte array returned by this function is likely bigger than the actual data required.  Read Pointer.Position
        /// after the operation to see where exactly the data ends
        /// </summary>
        /// <param name="p">the pointer indicating where in the return array the actual data stops.  We use this to keep from having to copy the data
        /// into a perfectly sized array.</param>
        /// <returns>a binary representation of the packet</returns>
        public virtual byte[] Serialize(Pointer p)
        {
            BitPacker.AddInt(ref m_SerializeBuffer, p, PacketID);
            BitPacker.AddLong(ref m_SerializeBuffer, p, SentOnUTC);
            return(m_SerializeBuffer);
        }
Esempio n. 27
0
 public override byte[] Serialize(Pointer p)
 {
     base.Serialize(p);
     BitPacker.AddInt(ref m_SerializeBuffer, p, ListenOnPort);
     return(m_SerializeBuffer);
 }