public static void FireOnPacketReceived(object sender, OnPacketReceivedEventArgs args)
 {
     if (OnPacketReceived != null) OnPacketReceived(sender, args);
 }
        public void OnPacketReceived(object sender, OnPacketReceivedEventArgs args)
        {
            if (request == null) return; // not awaiting request
            if (response != null) return; // already received a reply
            if ((Packet.Opcodes)args.Pak.Opcode != Packet.Opcodes.FunctionReply) return; // wrong packet opcode
            args.Pak.Pos = 0;
            string guid = args.Pak.ReadString();
            if (String.Compare(guid,request.Guid) != 0) return; // wrong function reply
            NativeFunction ret = new NativeFunction();
            ret.Guid = guid;
            ret.Name = args.Pak.ReadString();
            ret.Response = args.Pak.ReadInt32();
            ret.Args = args.Pak.ReadString();
            int datalength = args.Pak.Length - args.Pak.Pos;
            //Log.Debug("Good function reply received: " + ret.Name + " / " + ret.Response + " / " + ret.Args + " / " + args.Pak.Length + " / " + args.Pak.Pos + " / " + datalength);

            ret.Data.AddData(args.Pak.ReadData(datalength),datalength);
            response = ret;
        }