File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,6 +71,27 @@ public final class MSDPManager {
7171 nameIndex [ name]
7272 }
7373
74+ // MARK: - Copyover Support
75+
76+ /// Names of variables currently marked as reported (for copyover snapshot).
77+ public var reportedVariableNames : [ String ] {
78+ var names : [ String ] = [ ]
79+ for idx in 0 ..< definitions. count {
80+ if state [ idx] . flags. contains ( . reported) {
81+ names. append ( definitions [ idx] . name)
82+ }
83+ }
84+ return names
85+ }
86+
87+ /// Restore reported variable flags from a list of variable names (after copyover).
88+ public func restoreReportedVariables( _ names: [ String ] ) {
89+ for name in names {
90+ guard let idx = findIndex ( name) else { continue }
91+ state [ idx] . flags. insert ( . reported)
92+ }
93+ }
94+
7495 // MARK: - Reading
7596
7697 /// Get the current value of a variable, or nil if unknown.
Original file line number Diff line number Diff line change @@ -67,6 +67,28 @@ public final class TelnetSession {
6767 self . msdpTable = msdpTable
6868 }
6969
70+ /// Restore a TelnetSession from saved copyover state.
71+ /// Sets negotiated flags directly without sending announcements to the client.
72+ public init (
73+ restoring commFlags: CommFlags ,
74+ mttsFlags: MTTSFlags ,
75+ terminalType: String ,
76+ windowSize: ( cols: Int , rows: Int ) ,
77+ proxy: String ,
78+ delegate: TelnetSessionDelegate ? = nil ,
79+ telnetTable: [ TelnetOptionEntry ] = defaultTelnetTable,
80+ msdpTable: [ MSDPVariableDefinition ] = defaultMSDPTable
81+ ) {
82+ self . delegate = delegate
83+ self . telnetTable = telnetTable
84+ self . msdpTable = msdpTable
85+ self . commFlags = commFlags
86+ self . mttsFlags = mttsFlags
87+ self . terminalType = terminalType
88+ self . windowSize = windowSize
89+ self . proxy = proxy
90+ }
91+
7092 // MARK: - Connection Lifecycle
7193
7294 /// Announce support for negotiated telnet options.
You can’t perform that action at this time.
0 commit comments