GithubHelp home page GithubHelp logo

dp1994 / bonjour Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eugenebokhan/bonjour

0.0 1.0 0.0 104 KB

Easy-to-use Bonjour Service for iOS and macOS.

License: MIT License

Swift 97.42% Ruby 2.12% Shell 0.46%

bonjour's Introduction

Bonjour

Bonjour is a little service for easy communication with bonjour protocol supported devices.

Requirements

  • Swift 5.2
  • iOS 11.0
  • macOS 10.13

Install via Cocoapods

pod 'Bonjour'

How To Use

  • Init session

    let bonjour = BonjourSession(configuration: .init(configuration: .default))
  • Start / stop session:

    // Start broadcasting
    bonjour.start()
    
    // Stop broadcasting
    bonjour.stop()
  • Implement optional handlers:

    // On start receiving large package of data.
    bonjour.onStartRecieving = { resourceName, peer in ... }
    
    // Track large package of data receiving progress.
    bonjour.onReceiving = { resourceName, progress in ... }
    
    // On finish receiving large package of data.
    bonjour.onFinishRecieving = { resourceName, peer, localURL, error in ... }
    
    // On small package of data receive.
    bonjour.onReceive = { data, peer in ... }
    
    // On new peer discovery.
    bonjour.onPeerDiscovery = { peer in ... }
    
    // On loss of peer.
    bonjour.onPeerLoss = { peer in ... }
    
    // On connection to peer.
    bonjour.onPeerConnection = { peer in ... }
    
    // On disconnection from peer.
    bonjour.onPeerDisconnection = { peer in ... }
    
    // On update of list of available peers.
    bonjour.onAvailablePeersDidChange = { availablePeers in ... }
  • Send messages/data:

    // Send small package of data to all connected peers.
    bonjour.broadcast(_ data: Data)
    
    // Send small package of data to certain amount of connected peers.
    bonjour.send(_ data: Data, to peers: [Peer])
    
    // Send large package of data to a certain peer.
    bonjour.sendResource(at url: URL,
                         resourceName: String,
                         to peer: Peer,
                         progressHandler: ((Double) -> Void)?,
                         completionHandler: ((Error?) -> Void)?)

Author

Eugene Bokhan

Software Engineer
Twitter Github LinkedIn

License

Project's license is MIT.

bonjour's People

Contributors

eugenebokhan avatar

Watchers

James Cloos 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.