# Blocking calls

The application can block all incoming calls on a line and prevent placement of outbound calls on the line. While calls are being blocked, no call control events are generated for that line. Applications can also unblock calls that have been blocked.

## Blocking a call

To block calls on a line, the application invokes nccBlockCalls with the line handle. nccBlockCalls can be invoked from any line state or call state. Incoming calls are blocked on the line when the line state is idle because there are no active calls on the line.

Note: Outbound-only trunks typically cannot be blocked. Blocking a line is a valid action only when the trunk is capable of receiving calls (inbound-only or two-way trunks).

When invoking nccBlockCalls, specify the method to use to block calls:

Method | Description
--- | ---
NCC_BLOCK_REJECTALL | Do not answer subsequent calls
NCC_BLOCK_OUT_OF_SERVICE | Place the line out of service

The NCC service waits until there are no active calls on the line. The line then enters the blocking state. The application receives NCCEVN_CALLS_BLOCKED. The line remains in the blocking state until nccUnblockCalls is invoked.

The application may receive an incoming call event after invoking nccBlockCalls and before receiving NCCEVN_CALLS_BLOCKED. The application must handle the call, answering or rejecting it as necessary. Calls are not blocked, and the application does not receive NCCEVN_CALLS_BLOCKED until there are no active calls.

## Unblocking a call

To unblock calls on a line in blocking line state, the application invokes nccUnblockCalls, prompting the line state to change to idle. The application receives NCCEVN_CALLS_UNBLOCKED. At this point, the application can receive or place calls on the line.

The application can invoke nccUnblockCalls to cancel a previous nccBlockCalls invocation before the line state becomes idle. In this case, no events are received.

If the specified line is not in the blocking state, and no previously invoked nccBlockCalls is pending, nccUnblockCalls returns CTAERR_INVALID_STATE.