S2BEmitter

public final class S2BEmitter

Danmaku poster

  • Default emitter.

    Declaration

    Swift

    public static let `default` = S2BEmitter()
  • Suggested cool time between sending danmaku in seconds. Number smaller than the default may result in ban or failure.

    Declaration

    Swift

    public static let defaultDelay: Double = 3.5
  • Suggested cool time when received -636 (frequency too high) from bilibili. Number smaller than the default may result in ban or failure.

    Declaration

    Swift

    public static let defaultLongDelay: Double = 5 * 60
  • Initalize a S2BEmitter with specified session and delay.

    Declaration

    Swift

    public init(session: BKSession! = .shared, delay: Double = S2BEmitter.defaultDelay, longDelay: Double = S2BEmitter.defaultLongDelay)

    Parameters

    session

    session containing cookie required for posting danmaku.

    delay

    cool time between sending danmaku in seconds.

    longDelay

    seconds between -636 and sending next danmaku.

  • Initalize a S2BEmitter with specified cookie to add to the default session and delay.

    Declaration

    Swift

    public convenience init(cookie: BKCookie, delay: Double = S2BEmitter.defaultDelay, longDelay: Double = S2BEmitter.defaultLongDelay)

    Parameters

    cookie

    cookie to be added to the default session.

    delay

    cool time between sending danmaku in seconds.

    longDelay

    seconds between -636 and sending next danmaku.

  • Result after trying to post a danmaku.

    • success: danmaku was successfully posted.
    • refused: bilibili refused to accept the postable danmaku.
    • aborted: something else went wrong.
    See more

    Declaration

    Swift

    public enum Result
  • To handle result after tring to post a danmaku.

    Declaration

    Swift

    public typealias FailablePostCompletionHandler = (_ result: Result) -> Void

    Parameters

    result

    result after trying to post a danmaku.

  • Try to post a danmaku.

    Declaration

    Swift

    public func tryPost(danmaku: S2BDanmaku, toPage page: BKVideo.Page, completionHandler: FailablePostCompletionHandler? = nil)

    Parameters

    danmaku

    danmaku to post.

    completionHandler

    task to perform once tried.