<commit_before>//
//  ServiceAdvertiser.swift
//  Knuff
//
//  Created by <NAME> on 03/04/15.
//  Copyright (c) 2015 Bowtie. All rights reserved.
//

import Foundation
import MultipeerConnectivity

class ServiceAdvertiser: NSObject, MCNearbyServiceAdvertiserDelegate{

  var serviceAdvertiser: MCNearbyServiceAdvertiser?
  var deviceTokenString: String?
  
  func setDeviceToken(deviceToken: NSData?) {
    if let token = deviceToken {
      let tokenChars = UnsafePointer<CChar>(token.bytes)
      
      var tokenString = ""
      
      for var i = 0; i < token.length; i++ {
        tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]])
      }
      
      deviceTokenString = tokenString
    }
    else {
      deviceTokenString = nil
    }
    
    advertise()
  }
  
  func advertise() {
    if let advertiser = serviceAdvertiser {
      advertiser.stopAdvertisingPeer()
    }
    
    
    if let tokenString = deviceTokenString {
      let peerID = MCPeerID(displayName: UIDevice.currentDevice().name)
      
      serviceAdvertiser = MCNearbyServiceAdvertiser(
        peer: peerID,
        discoveryInfo: ["token": tokenString, "type": "iOS"],
        serviceType: "apns-pusher"
      )
      
      serviceAdvertiser?.delegate = self
      
      serviceAdvertiser?.startAdvertisingPeer();
    }
  }
  
  // MARK: - MCNearbyServiceAdvertiserDelegate
  
  func advertiser(advertiser: MCNearbyServiceAdvertiser!, didNotStartAdvertisingPeer error: NSError!) {}
  
  func advertiser(advertiser: MCNearbyServiceAdvertiser!, didReceiveInvitationFromPeer peerID: MCPeerID!, withContext context: NSData!, invitationHandler: ((Bool, MCSession!) -> Void)!) {
    invitationHandler(false, nil)
  }
}
<commit_msg>Change service name to "knuff".<commit_after>//
//  ServiceAdvertiser.swift
//  Knuff
//
//  Created by <NAME> on 03/04/15.
//  Copyright (c) 2015 Bowtie. All rights reserved.
//

import Foundation
import MultipeerConnectivity

class ServiceAdvertiser: NSObject, MCNearbyServiceAdvertiserDelegate{

  var serviceAdvertiser: MCNearbyServiceAdvertiser?
  var deviceTokenString: String?
  
  func setDeviceToken(deviceToken: NSData?) {
    if let token = deviceToken {
      let tokenChars = UnsafePointer<CChar>(token.bytes)
      
      var tokenString = ""
      
      for var i = 0; i < token.length; i++ {
        tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]])
      }
      
      deviceTokenString = tokenString
    }
    else {
      deviceTokenString = nil
    }
    
    advertise()
  }
  
  func advertise() {
    if let advertiser = serviceAdvertiser {
      advertiser.stopAdvertisingPeer()
    }
    
    
    if let tokenString = deviceTokenString {
      let peerID = MCPeerID(displayName: UIDevice.currentDevice().name)
      
      serviceAdvertiser = MCNearbyServiceAdvertiser(
        peer: peerID,
        discoveryInfo: ["token": tokenString],
        serviceType: "knuff"
      )
      
      serviceAdvertiser?.delegate = self
      
      serviceAdvertiser?.startAdvertisingPeer();
    }
  }
  
  // MARK: - MCNearbyServiceAdvertiserDelegate
  
  func advertiser(advertiser: MCNearbyServiceAdvertiser!, didNotStartAdvertisingPeer error: NSError!) {}
  
  func advertiser(advertiser: MCNearbyServiceAdvertiser!, didReceiveInvitationFromPeer peerID: MCPeerID!, withContext context: NSData!, invitationHandler: ((Bool, MCSession!) -> Void)!) {
    invitationHandler(false, nil)
  }
}

{'fraction_non_alphanumeric': 0.09892970783916691, 'fraction_numerical': 0.00809950824414232, 'mean_word_length': 3.016260162601626, 'pattern_counts': {'":': 3, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5616381', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1069, 'n_words': 224}