Safe Haskell | None |
---|---|
Language | Haskell2010 |
DMCC.Agent
Description
Agents in a DMCC API session enable call control over devices.
Synopsis
- data Action
- = MakeCall { }
- | AnswerCall { }
- | EndCall { }
- | HoldCall { }
- | RetrieveCall { }
- | BargeIn { }
- | ConferenceCall {
- activeCall :: CallId
- heldCall :: CallId
- | TransferCall {
- activeCall :: CallId
- heldCall :: CallId
- | SendDigits { }
- | SetState { }
- data AgentSnapshot = AgentSnapshot {}
- state :: Lens' AgentSnapshot (Maybe AgentState, Text)
- calls :: Lens' AgentSnapshot (Map CallId Call)
- data AgentEvent
- = TelephonyEvent { }
- | StateChange { }
- | TelephonyEventError { }
- | RequestError { }
- data WHEvent = WHEvent {
- agentId :: AgentId
- event :: AgentEvent
- data Agent = Agent {}
- newtype AgentHandle = AgentHandle (AgentId, Session)
- data AgentError
- agentAction :: (MonadLoggerIO m, MonadCatch m) => Action -> AgentHandle -> m ()
- placeAgentLock :: AgentHandle -> STM ()
- releaseAgentLock :: MonadLoggerIO m => AgentHandle -> m ()
- controlAgent :: (MonadUnliftIO m, MonadLoggerIO m, MonadBaseControl IO m, MonadMask m) => SwitchName -> Extension -> Session -> m (Either AgentError AgentHandle)
- processAgentAction :: (MonadUnliftIO m, MonadLoggerIO m, MonadBaseControl IO m, MonadCatch m) => AgentId -> DeviceId -> TVar AgentSnapshot -> Session -> Action -> m ()
- processAgentEvent :: (MonadUnliftIO m, MonadBaseControl IO m, MonadLoggerIO m, MonadCatch m) => AgentId -> DeviceId -> TVar AgentSnapshot -> TChan AgentEvent -> Session -> Response -> m ()
- sendWH :: (MonadUnliftIO m, MonadLoggerIO m, MonadCatch m) => (Request, Manager) -> AgentId -> AgentEvent -> m ()
- releaseAgent :: (MonadUnliftIO m, MonadLoggerIO m, MonadBaseControl IO m, MonadCatch m) => AgentHandle -> m ()
- handleEvents :: (MonadLoggerIO m, MonadThrow m) => AgentHandle -> (AgentEvent -> m ()) -> m ThreadId
- getAgentSnapshot :: (MonadLoggerIO m, MonadThrow m) => AgentHandle -> m AgentSnapshot
Documentation
Actions performable by a controlled agent.
Constructors
MakeCall | |
AnswerCall | |
EndCall | |
HoldCall | |
RetrieveCall | |
BargeIn | |
Fields
| |
ConferenceCall | |
Fields
| |
TransferCall | |
Fields
| |
SendDigits | |
SetState | |
Fields |
data AgentSnapshot Source #
Constructors
AgentSnapshot | |
Instances
Show AgentSnapshot Source # | |
Defined in DMCC.Agent Methods showsPrec :: Int -> AgentSnapshot -> ShowS # show :: AgentSnapshot -> String # showList :: [AgentSnapshot] -> ShowS # | |
ToJSON AgentSnapshot Source # | |
Defined in DMCC.Agent Methods toJSON :: AgentSnapshot -> Value # toEncoding :: AgentSnapshot -> Encoding # toJSONList :: [AgentSnapshot] -> Value # toEncodingList :: [AgentSnapshot] -> Encoding # | |
FromJSON AgentSnapshot Source # | |
Defined in DMCC.Agent Methods parseJSON :: Value -> Parser AgentSnapshot # parseJSONList :: Value -> Parser [AgentSnapshot] # |
state :: Lens' AgentSnapshot (Maybe AgentState, Text) Source #
data AgentEvent Source #
Events/errors are published to external clients of the agents and may be used by agent subscribers to provide information to user.
Constructors
TelephonyEvent | A telephony-related event, along with an updated snapshot. |
Fields | |
StateChange | Arrives when an agent state change has been observed. |
Fields | |
TelephonyEventError | An error caused by a telephony-related event. |
RequestError | An error caused by a request from this agent. |
Instances
Show AgentEvent Source # | |
Defined in DMCC.Agent Methods showsPrec :: Int -> AgentEvent -> ShowS # show :: AgentEvent -> String # showList :: [AgentEvent] -> ShowS # | |
ToJSON AgentEvent Source # | |
Defined in DMCC.Agent Methods toJSON :: AgentEvent -> Value # toEncoding :: AgentEvent -> Encoding # toJSONList :: [AgentEvent] -> Value # toEncodingList :: [AgentEvent] -> Encoding # | |
FromJSON AgentEvent Source # | |
Defined in DMCC.Agent |
Web hook event.
Constructors
WHEvent | |
Fields
|
An agent controlled by a DMCC API session.
Constructors
Agent | |
Fields
|
newtype AgentHandle Source #
Constructors
AgentHandle (AgentId, Session) |
Instances
Eq AgentHandle Source # | |
Defined in DMCC.Agent | |
Ord AgentHandle Source # | |
Defined in DMCC.Agent Methods compare :: AgentHandle -> AgentHandle -> Ordering # (<) :: AgentHandle -> AgentHandle -> Bool # (<=) :: AgentHandle -> AgentHandle -> Bool # (>) :: AgentHandle -> AgentHandle -> Bool # (>=) :: AgentHandle -> AgentHandle -> Bool # max :: AgentHandle -> AgentHandle -> AgentHandle # min :: AgentHandle -> AgentHandle -> AgentHandle # | |
Show AgentHandle Source # | |
Defined in DMCC.Agent Methods showsPrec :: Int -> AgentHandle -> ShowS # show :: AgentHandle -> String # showList :: [AgentHandle] -> ShowS # |
data AgentError Source #
Exceptions thrown by agent-related routines and threads.
Instances
Data AgentError Source # | |
Defined in DMCC.Agent Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> AgentError -> c AgentError # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c AgentError # toConstr :: AgentError -> Constr # dataTypeOf :: AgentError -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c AgentError) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AgentError) # gmapT :: (forall b. Data b => b -> b) -> AgentError -> AgentError # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AgentError -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AgentError -> r # gmapQ :: (forall d. Data d => d -> u) -> AgentError -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> AgentError -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> AgentError -> m AgentError # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> AgentError -> m AgentError # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> AgentError -> m AgentError # | |
Show AgentError Source # | |
Defined in DMCC.Agent Methods showsPrec :: Int -> AgentError -> ShowS # show :: AgentError -> String # showList :: [AgentError] -> ShowS # | |
Exception AgentError Source # | |
Defined in DMCC.Agent Methods toException :: AgentError -> SomeException # fromException :: SomeException -> Maybe AgentError # displayException :: AgentError -> String # |
agentAction :: (MonadLoggerIO m, MonadCatch m) => Action -> AgentHandle -> m () Source #
Command an agent to do something.
Due to lack of global locking of the agents map an agent may be gone (released) by the time an action arrives to its actionChan. This is by design to avoid congestion during action processing.
placeAgentLock :: AgentHandle -> STM () Source #
releaseAgentLock :: MonadLoggerIO m => AgentHandle -> m () Source #
controlAgent :: (MonadUnliftIO m, MonadLoggerIO m, MonadBaseControl IO m, MonadMask m) => SwitchName -> Extension -> Session -> m (Either AgentError AgentHandle) Source #
Enable an active agent to be monitored and controlled through DMCC API. If the agent has already been registered, return the old entry (it's safe to call this function with the same arguments multiple times).
processAgentAction :: (MonadUnliftIO m, MonadLoggerIO m, MonadBaseControl IO m, MonadCatch m) => AgentId -> DeviceId -> TVar AgentSnapshot -> Session -> Action -> m () Source #
Translate agent actions into actual DMCC API requests.
TODO Allow agents to control only own calls.
processAgentEvent :: (MonadUnliftIO m, MonadBaseControl IO m, MonadLoggerIO m, MonadCatch m) => AgentId -> DeviceId -> TVar AgentSnapshot -> TChan AgentEvent -> Session -> Response -> m () Source #
Process DMCC API events/errors for this agent to change its snapshot and broadcast events further.
sendWH :: (MonadUnliftIO m, MonadLoggerIO m, MonadCatch m) => (Request, Manager) -> AgentId -> AgentEvent -> m () Source #
Send agent event data to a web hook endpoint, ignoring possible exceptions.
releaseAgent :: (MonadUnliftIO m, MonadLoggerIO m, MonadBaseControl IO m, MonadCatch m) => AgentHandle -> m () Source #
Forget about an agent, releasing his device and monitors.
handleEvents :: (MonadLoggerIO m, MonadThrow m) => AgentHandle -> (AgentEvent -> m ()) -> m ThreadId Source #
Attach an event handler to an agent. Exceptions are not handled.
getAgentSnapshot :: (MonadLoggerIO m, MonadThrow m) => AgentHandle -> m AgentSnapshot Source #