tox.py 文件源码

python
阅读 69 收藏 0 点赞 0 评论 0

项目:milisia-tox 作者: milisarge 项目源码 文件源码
def callback_file_chunk_request(self, callback, user_data):
        """
        Set the callback for the `file_chunk_request` event. Pass None to unset.

        This event is triggered when Core is ready to send more file data.

        :param callback: Python function.
        If the length parameter is 0, the file transfer is finished, and the client's resources associated with the file
        number should be released. After a call with zero length, the file number can be reused for future file
        transfers.

        If the requested position is not equal to the client's idea of the current file or stream position, it will need
        to seek. In case of read-once streams, the client should keep the last read chunk so that a seek back can be
        supported. A seek-back only ever needs to read from the last requested chunk. This happens when a chunk was
        requested, but the send failed. A seek-back request can occur an arbitrary number of times for any given chunk.

        In response to receiving this callback, the client should call the function `tox_file_send_chunk` with the
        requested chunk. If the number of bytes sent through that function is zero, the file transfer is assumed
        complete. A client must send the full length of data requested with this callback.

        Should take pointer (c_void_p) to Tox object,
        The friend number (c_uint32) of the receiving friend for this file.
        The file transfer identifier (c_uint32) returned by tox_file_send.
        The file or stream position (c_uint64) from which to continue reading.
        The number of bytes (c_size_t) requested for the current chunk.
        pointer (c_void_p) to user_data
        :param user_data: pointer (c_void_p) to user data
        """
        c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_uint32, c_uint64, c_size_t, c_void_p)
        self.file_chunk_request_cb = c_callback(callback)
        self.libtoxcore.tox_callback_file_chunk_request(self._tox_pointer, self.file_chunk_request_cb, user_data)

    # -----------------------------------------------------------------------------------------------------------------
    # File transmission: receiving
    # -----------------------------------------------------------------------------------------------------------------
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号