MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / w_agent_login

Function w_agent_login

modules/call_center/call_center.c:1285–1332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1283
1284
1285static int w_agent_login(struct sip_msg *req, str *agent_s, int *state)
1286{
1287 struct cc_agent *agent, *prev_agent;
1288
1289 /* block access to data */
1290 lock_get( data->lock );
1291
1292 /* name of the agent */
1293 agent = get_agent_by_name( data, agent_s, &prev_agent);
1294 if (agent==NULL) {
1295 lock_release( data->lock );
1296 LM_DBG("agent <%.*s> not found\n",agent_s->len,agent_s->s);
1297 return -3;
1298 }
1299
1300 if (agent->logged_in != *state) {
1301
1302 if(*state) {
1303 if ( agent->state==CC_AGENT_WRAPUP &&
1304 get_ticks() > agent->wrapup_end_time )
1305 agent->state = CC_AGENT_FREE;
1306
1307 if ( agent->state==CC_AGENT_INCHAT &&
1308 get_ticks() > agent->wrapup_end_time &&
1309 agent->ongoing_sessions[CC_MEDIA_MSRP]==0 )
1310 agent->state = CC_AGENT_FREE;
1311
1312 if(data->agents[CC_AG_ONLINE] == NULL)
1313 data->last_online_agent = agent;
1314 }
1315
1316 /* agent event is triggered here */
1317 agent_switch_login(data, agent, prev_agent);
1318
1319 if(*state) {
1320 data->loggedin_agents++;
1321 log_agent_to_flows( data, agent, 1);
1322 } else {
1323 data->loggedin_agents--;
1324 log_agent_to_flows(data, agent, 0);
1325 }
1326 }
1327
1328 /* release access to data */
1329 lock_release( data->lock );
1330
1331 return 1;
1332}
1333
1334
1335static void cc_timer_agents(unsigned int ticks, void* param)

Callers

nothing calls this directly

Calls 6

lock_getFunction · 0.85
get_agent_by_nameFunction · 0.85
lock_releaseFunction · 0.85
get_ticksFunction · 0.85
agent_switch_loginFunction · 0.85
log_agent_to_flowsFunction · 0.85

Tested by

no test coverage detected