<commit_before>//
//  YepMessageService.swift
//  Yep
//
//  Created by kevinzhow on 15/3/26.
//  Copyright (c) 2015年 Catch Inc. All rights reserved.
//

import UIKit
import MZFayeClient

class FayeService: NSObject, MZFayeClientDelegate {

    static let sharedManager = FayeService()

    let client: MZFayeClient

    override init() {

        client = MZFayeClient(URL:NSURL(string: "http://faye.catchchatchina.com/faye"))
        
        super.init()
        
        client.delegate = self
    }

    // MARK: Public

    func startConnect() {
        if
            let v1AccessToken = YepUserDefaults.v1AccessToken(),
            let userID = YepUserDefaults.userID() {
                let extensionData = [
                    "access_token": v1AccessToken,
                    "mobile": "18620855007",
                    "phone_code": "86"
                ]

                let personalChannel = personalChannelWithUserID(userID)

                println("Will Subscribe \(personalChannel)")
                client.setExtension(extensionData, forChannel: personalChannel)
                client.connect()
                client.subscribeToChannel(personalChannel)


        } else {<commit_msg>not need phone number in Faye extension<commit_after>//
//  YepMessageService.swift
//  Yep
//
//  Created by kevinzhow on 15/3/26.
//  Copyright (c) 2015年 Catch Inc. All rights reserved.
//

import Foundation
import MZFayeClient

class FayeService: NSObject, MZFayeClientDelegate {

    static let sharedManager = FayeService()

    let client: MZFayeClient

    override init() {

        client = MZFayeClient(URL:NSURL(string: "http://faye.catchchatchina.com/faye"))
        
        super.init()
        
        client.delegate = self
    }

    // MARK: Public

    func startConnect() {
        if
            let v1AccessToken = YepUserDefaults.v1AccessToken(),
            let userID = YepUserDefaults.userID() {
                let extensionData = [
                    "access_token": v1AccessToken,
                ]

                let personalChannel = personalChannelWithUserID(userID)

                println("Will Subscribe \(personalChannel)")
                client.setExtension(extensionData, forChannel: personalChannel)
                client.connect()
                client.subscribeToChannel(personalChannel)

        } else {
{'fraction_non_alphanumeric': 0.09102455546147332, 'fraction_numerical': 0.015664690939881456, 'mean_word_length': 1.9390547263681592, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, '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': '4368433', 'n_tokens_mistral': 707, 'n_tokens_neox': 634, 'n_words': 142}