-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOutlet.swift
More file actions
36 lines (28 loc) · 734 Bytes
/
Outlet.swift
File metadata and controls
36 lines (28 loc) · 734 Bytes
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
//
// Outlet.swift
// LabStreamingLayer
//
// Created by Maximilian Kraus on 16.01.20.
// Copyright © 2020 Maximilian Kraus. All rights reserved.
//
import Foundation
public class Outlet {
let base: lsl_outlet
let streamInfo: StreamInfo
public init(streamInfo: StreamInfo) {
self.streamInfo = streamInfo
self.base = lsl_create_outlet(streamInfo.base, 0, 1)
}
}
extension Outlet {
public var hasConsumers: Bool {
lsl_have_consumers(base) > 0
}
public func push(data: String) throws {
guard streamInfo.channelFormat == .string else { throw Error.argument }
let errorCode = lsl_push_sample_c(base, data)
if errorCode != 0 {
throw Error(rawValue: errorCode)!
}
}
}