Skip to content

Commit

Permalink
SystemAgent 의 Nodirective Directive를 notification에 추가 (#1076)
Browse files Browse the repository at this point in the history
### Description
- SystemAgent 의 Nodirective Directive를 notification에 추가
  • Loading branch information
jayce1116 authored Aug 25, 2023
1 parent 4999450 commit 18776eb
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion NuguAgents/Sources/CapabilityAgents/System/SystemAgent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public final class SystemAgent: SystemAgentProtocol {
DirectiveHandleInfo(namespace: capabilityAgentProperty.name, name: "UpdateState", blockingPolicy: BlockingPolicy(medium: .none, isBlocking: false), directiveHandler: handleUpdateState),
DirectiveHandleInfo(namespace: capabilityAgentProperty.name, name: "Exception", blockingPolicy: BlockingPolicy(medium: .none, isBlocking: false), directiveHandler: handleException),
DirectiveHandleInfo(namespace: capabilityAgentProperty.name, name: "Revoke", blockingPolicy: BlockingPolicy(medium: .none, isBlocking: false), directiveHandler: handleRevoke),
DirectiveHandleInfo(namespace: capabilityAgentProperty.name, name: "NoDirectives", blockingPolicy: BlockingPolicy(medium: .none, isBlocking: false), directiveHandler: { { $1(.finished) } }),
DirectiveHandleInfo(namespace: capabilityAgentProperty.name, name: "NoDirectives", blockingPolicy: BlockingPolicy(medium: .none, isBlocking: false), directiveHandler: handleNoDirectives),
DirectiveHandleInfo(namespace: capabilityAgentProperty.name, name: "Noop", blockingPolicy: BlockingPolicy(medium: .none, isBlocking: false), directiveHandler: { { $1(.finished) } }),
DirectiveHandleInfo(namespace: capabilityAgentProperty.name, name: "ResetConnection", blockingPolicy: BlockingPolicy(medium: .none, isBlocking: false), directiveHandler: handleResetConnection)
]
Expand Down Expand Up @@ -138,6 +138,16 @@ private extension SystemAgent {
}
}

func handleNoDirectives() -> HandleDirective {
return { [weak self] directive, completion in
defer { completion(.finished) }

self?.systemDispatchQueue.async { [weak self] in
self?.post(NuguAgentNotification.System.NoDirective(header: directive.header))
}
}
}

func handleResetConnection() -> HandleDirective {
return { [weak self] _, completion in
defer { completion(.finished) }
Expand Down Expand Up @@ -173,6 +183,7 @@ private extension SystemAgent {
extension Notification.Name {
static let systemAgentDidReceiveExceptionFail = Notification.Name("com.sktelecom.romaine.notification.name.system_agent_did_receive_exception_fail")
static let systemAgentDidReceiveRevokeDevice = Notification.Name("com.sktelecom.romaine.notification.name.system_agent_did_revoke_device")
static let systemAgentDidReceiveNoDirective = Notification.Name("com.sktelecom.romaine.notification.name.system_agent_no_directive")
}

public extension NuguAgentNotification {
Expand Down Expand Up @@ -202,5 +213,16 @@ public extension NuguAgentNotification {
return RevokeDevice(reason: reason, header: header)
}
}

public struct NoDirective: TypedNotification {
static public var name: Notification.Name = .systemAgentDidReceiveNoDirective
public let header: Downstream.Header

public static func make(from: [String: Any]) -> NoDirective? {
guard let header = from["header"] as? Downstream.Header else { return nil }

return NoDirective(header: header)
}
}
}
}

0 comments on commit 18776eb

Please sign in to comment.