Пример #1
0
 public static extern int CallbackLossyPacket(ToxHandle tox, int friendnumber, byte start_byte, ToxDelegates.CallbackPacketDelegate callback, IntPtr obj);
Пример #2
0
 public static extern int RegisterLosslessPacketCallback(ToxHandle tox, int friendnumber, byte start_byte, ToxDelegates.CallbackPacketDelegate callback, IntPtr obj);
Пример #3
0
        /// <summary>
        /// Registers a handler for lossless packets starting with start_byte. These packets can be captured with <see cref="OnLosslessPacket"/>.
        /// </summary>
        /// <param name="friendnumber"></param>
        /// <param name="start_byte"></param>
        /// <returns></returns>
        public bool RegisterLosslessPacketHandler(int friendnumber, byte start_byte)
        {
            if (disposed)
                throw new ObjectDisposedException(GetType().FullName);

            if (start_byte < 160 || start_byte > 191)
                throw new ArgumentException("start_byte is not in the 160-191 range.");

            ToxDelegates.CallbackPacketDelegate del = new ToxDelegates.CallbackPacketDelegate((IntPtr obj, byte[] data, uint length) =>
            {
                if (OnLosslessPacket != null)
                    Invoker(OnLosslessPacket, friendnumber, data);

                return 1;

            });
            losslessPacketHandlers.Add(del);

            return ToxFunctions.CallbackLosslessPacket(tox, friendnumber, start_byte, del, IntPtr.Zero) == 0;
        }