-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLCSlaveFacade.swift
37 lines (30 loc) · 977 Bytes
/
LCSlaveFacade.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
//
// SlaveSyncWrapper.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 LCSlaveFacade {
private let syncService: LCSlaveService
public var delegate: LCSlaveFacadeDelegate?
public required init() {
self.syncService = LCSlaveService()
self.syncService.delegate = self
}
public func sendData(_ data: Data) throws {
try syncService.sendDataToMasters(data: data)
}
public func finishConnection() {
syncService.finishConnection()
syncService.delegate = nil
delegate = nil
}
}
extension LCSlaveFacade: LCSlaveServiceDelegate {
func slaveSyncService(_ sender: LCSlaveService, didReceiveDataFromMaster data: Data, with peerId: MCPeerID) {
self.delegate?.didReceiveData(data, fromPeer: peerId)
}
}