-
Notifications
You must be signed in to change notification settings - Fork 0
/
LCMasterFacade.swift
38 lines (30 loc) · 955 Bytes
/
LCMasterFacade.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// Master.swift
// SincProject
//
// Created by Luis Gustavo Avelino de Lima Jacinto on 20/09/19.
// Copyright © 2019 Luis Gustavo Avelino de Lima Jacinto. All rights reserved.
//
import Foundation
import MultipeerConnectivity
public class LCMasterFacade {
private let syncService: LCMasterService
public var delegate: LCMasterFacadeDelegate?
public required init() {
self.syncService = LCMasterService()
self.syncService.delegate = self
}
public func sendData(_ data: Data) throws {
try syncService.sendDataToSlaves(data: data)
}
public func finishSession() {
syncService.finishSession()
syncService.delegate = nil
delegate = nil
}
}
extension LCMasterFacade: LCMasterServiceDelegate {
func masterSyncService(_ sender: LCMasterService, didReceive data: Data, with peerId: MCPeerID) {
self.delegate?.didReceiveData(data, fromPeer: peerId)
}
}