Code Monkey home page Code Monkey logo

swift-scuttlebutt's Introduction

Swift Scuttlebutt

This is an experimental not finished implimentation of secure scuttlebutt in swift. It's released here in case anybody finds it useful.

Letting the Bot Scuttle

  1. Bring the library to your project:

    import Scuttlebutt
  2. Set up your bot:

    let bot = ScuttleBot()
    • TODO: What are the defaults?
    • TODO: Where to find information about the advanced setup?
  3. Subscribe to status updates:

    let activitySubscription = bot.activity.sink { status in
         switch status {
         case .ready: 
             print("Yay, the bot is ready to scuttle!")
         case .willDiscoverPeers:
             print("About to announce presence and search for peers...")
         case .peerDiscoveryComplete(let stats):
             print("Peer discovery complete: \(stats);")
         case .willRefresh:
             print("About to refresh...")
         case .refreshComplete(let stats):
             print("Refresh cycle complete: \(stats)")
         case .cancelled:
             print("The bot has been gracefully switched off.")
         case .failed(let error):
             print("OOOOPS! SOMETHING BAD HAPPENED WITH THE BOT!" )
             print("Cause: \(error)")
         }
    }
  4. Refresh at will:

    bot.refresh(from: .background)

    NOTE

    Calling refresh multiple times one after another will not schedule that amount of refresh operations. In order to provide maximum level of consistency, the actual execution of operations is scheduled adaptively, by the bot itself. The effective configuration of the next refresh largly depends on the receiver's quality of service class; for example: a userInitiated refresh will be executed as soon as possible, while the one scheduled from the background will be deferred until the most opportune moment.

    • TODO: Where to find more about scheduling?
  5. Cancel whenever ready to terminate you application:

    bot.cancel()
    activitySubscription.cancel()

    CAUTION

    Don't forget that the caller is responsible for cancelling the subscription.

swift-scuttlebutt's People

Contributors

irisdelaluna avatar rabble avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.