Ejemplo n.º 1
0
        private void Spy_OnPacketSafe(byte[] data, bool fromClient, DateTime time)
        {
            UltimaPacket packet = null;

            try
            {
                packet = UltimaPacket.ConstructPacket(data, fromClient, time);
            }
            catch (Exception ex)
            {
                App.Window.ShowNotification(NotificationType.Error, ex);
            }

            if (packet != null)
            {
                AddPacket(packet);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads packets from binary file.
        /// </summary>
        /// <param name="filePath">File to read from.</param>
        public void LoadBinary(string filePath)
        {
            List <UltimaPacket> packets = new List <UltimaPacket>();

            using (FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    int version = reader.ReadInt32();

                    if (version > 0)
                    {
                        throw new SpyException("Unsupported file version");
                    }

                    int count = reader.ReadInt32();

                    for (int i = 0; i < count; i++)
                    {
                        try
                        {
                            UltimaPacket packet = UltimaPacket.ConstructPacket(reader);

                            if (packet != null)
                            {
                                packets.Add(packet);
                            }
                        }
                        catch (Exception ex)
                        {
                            App.Window.ShowNotification(NotificationType.Error, ex);
                        }
                    }
                }
            }

            App.Current.Dispatcher.BeginInvoke(new Action <List <UltimaPacket> >(LoadBinary_Completed), packets);
        }