Safe Haskell | None |
---|---|
Language | Haskell2010 |
Agents in a DMCC API session enable call control over devices.
- 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.
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.
TelephonyEvent | A telephony-related event, along with an updated snapshot. |
StateChange | Arrives when an agent state change has been observed. |
TelephonyEventError | An error caused by a telephony-related event. |
RequestError | An error caused by a request from this agent. |
Web hook event.
WHEvent | |
|
An agent controlled by a DMCC API session.
Agent | |
|
newtype AgentHandle Source #
data AgentError Source #
Exceptions thrown by agent-related routines and threads.
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 #