📄 conferencecontrol.cxx
字号:
} if (cmd.getOp()=="conf_connect_received"){ cerr << "CC: connect receieved: "+cmd.getParam()<< endl; string remote=addDomainToPrefix(cmd.getParam()); pendingList.push_back((ConfMember(remote, cmd.getDestinationId()))); //cerr<<"call is accepted=>pending list: "<<endl; //printList(&pendingList); sendUpdatesToGui(); string users; for(int t=0;t<connectedList.size();t++) users=users+ ((connectedList[t]).uri) + ";"; //was connectedList.uris[t]+";"; //cerr<<"users "+users<<endl; CommandString c(cmd); c.setParam2(users); c.setOp(SipCommandString::accept_invite); //command.setParam2((string) &connectedList); //cerr<<"(string) &connectedList************** "+(&connectedList)<<endl; callback->confcb_handleSipCommand(c); //displayMessage("ERROR: "+cmd.getParam(), red); } if (cmd.getOp()==SipCommandString::remote_hang_up){ //state="IDLE"; //setPrompt(state); removeMember(cmd.getDestinationId()); sendUpdatesToGui(); cerr << "CC: Remote user ended the call."<< endl; //displayMessage("Remote user ended the call.",red); callId=""; //FIXME: should check the callId of cmd. } if (cmd.getOp()==SipCommandString::transport_error){ //state="IDLE"; //setPrompt(state); removeMember(cmd.getDestinationId()); sendUpdatesToGui(); cerr << "CC: The call could not be completed because of a network error."<< endl; //displayMessage("The call could not be completed because of a network error.", red); } if (cmd.getOp()=="error_message"){ cerr << "CC: ERROR: "+cmd.getParam()<< endl; //displayMessage("ERROR: "+cmd.getParam(), red); } if (cmd.getOp()=="remote_reject"){ removeMember(cmd.getDestinationId()); sendUpdatesToGui(); cerr << "CC: The remote user rejected the call."<< endl; //displayMessage("The remote user rejected the call.", red); } /*if (cmd.getOp()==SipCommandString::incoming_available){ if(!inCall){ state="ANSWER?"; setPrompt(state); callId=cmd.getDestinationId(); displayMessage("The incoming call from "+cmd.getParam(), blue); } else{ displayMessage("You missed call from "+cmd.getParam(), red); CommandString hup(cmd.getDestinationId(), SipCommandString::reject_invite); callback->guicb_handleCommand(hup); } }*/ /**** * p2tAddUser * DestinationID: CallId (SipDialogP2Tuser) * Param1: SIP URI * Description: a remote user wants to be added to a P2T Session. * This command is received when the SipDialogP2Tuser * is in the RINGING state and waits for an accept. ****/ /*else if (cmd.getOp()=="p2tAddUser"){ if(inCall==true && p2tmode==true){ //send automatically an accept back CommandString command(cmd.getDestinationId(), SipCommandString::accept_invite); callback->guicb_handleCommand(command); if(grpList->isParticipant(cmd.getParam())==false){ grpList->addUser(cmd.getParam()); displayMessage("User " + cmd.getParam() + " added!", blue); } } else if(inCall==true && p2tmode==false){ //do nothing, because //the user has first to accept or deny //a incoming P2T Session. The answer will //be sent there to this user } }*/ /**** * p2tRemoveUser * DestinationID: GroupId (SipDialogP2T) * Param1: SIP URI * Param2: reason * Description: a remote user wants to be added to a P2T Session. * This command is received when the SipDialogP2Tuser * is in the RINGING state and waits for an accept. ****/ /*else if (cmd.getOp()=="p2tRemoveUser"){ if(inCall==true && p2tmode==true){ displayMessage("User " + cmd.getParam() + " removed ("+ cmd.getParam2() +").", red); grpList->removeUser(cmd.getParam()); } }*/ /**** * p2tModifyUser * DestinationID: GroupId (SipDialogP2T) * Param1: SIP URI * Param2: status * Description: information about a state (in the floor control) * of a user. ****/ /*else if (cmd.getOp()=="p2tModifyUser"){ if(inCall==true && p2tmode==true){ int status=0; for(uint32_t k=0;k<cmd.getParam2().size();k++) status = (status*10) + (cmd.getParam2()[k]-'0'); grpList->getUser(cmd.getParam())->setStatus(status); } }*/ /**** * p2tInvitation * DestinationID: GroupID (SipDialogP2T) * Param1: Group Member List (XML-code) * Param2: uri inviting user * * Description: an invitation to a P2T Session ****/ /*else if (cmd.getOp()=="p2tInvitation"){ //if already in a call, send DENY back if(inCall){ //Close SipDialogP2T //CommandString cmd_term(cmd.getDestinationId(), "p2tTerminate"); //callback->guicb_handleCommand(cmd_term); //inform SipDialogP2Tuser //CommandString cmd_rej(cmd.getParam3(), SipCommandString::reject_invite); //callback->guicb_handleCommand(cmd_rej); //displayMessage("You missed P2T invitation from " + cmd.getParam2() +".", red); } //aks user to accept else{ inCall=true; grpList = new GroupList(cmd.getParam()); inviting_user=cmd.getParam2(); //inviting_callId=cmd.getParam3(); p2tGroupId=grpList->getGroupIdentity(); displayMessage(inviting_user + " invited you to a P2T Session:", blue); showGroupList(); displayMessage("type 'accept' or 'deny'", blue); state="P2T ACCEPT?"; setPrompt("P2T ACCEPT?"); } }*/ /**** * p2tSessionCreated * DestinationID: * Param1: GroupId (SipDialogP2T) * Param2: * Param3: * Description: the P2T Session is set up ****/ /*else if (cmd.getOp()=="p2tSessionCreated"){ p2tGroupId=cmd.getParam(); displayMessage("P2T Session "+ p2tGroupId + " created", green); grpList->setGroupIdentity(p2tGroupId); state="P2T CONNECTED"; setPrompt(state); } else if (cmd.getOp().substr(0,3)=="p2t"){ displayMessage("Received: "+cmd.getOp(), blue); }*/}/*** Moves a member from pending to connected and look for new members*/void ConferenceControl::sendUpdatesToGui(){ string connectedusers=""; int t; for(t=0;t<connectedList.size();t++) connectedusers=connectedusers+ ((connectedList[t]).uri) + ", "; //cerr<<"users "+connectedusers<<endl; string pendingusers=""; for(t=0;t<pendingList.size();t++) pendingusers=pendingusers+ ((pendingList[t]).uri) + ", "; //cerr<<"users "+pendingusers<<endl; CommandString cmd(confId,"list updated",connectedusers,pendingusers); callback->confcb_handleGuiCommand(cmd);}void ConferenceControl::handleOkAck(string callid, minilist<ConfMember> *conflist) { pendingToConnected(callid); updateLists(conflist); sendUpdatesToGui();} /*** Print a list of conference members*/void ConferenceControl::printList(minilist<ConfMember> *conflist) { for (int i = 0; i < conflist->size(); i++ ) { cerr << "Member : " + ((*conflist)[i]).uri << endl; cerr << "CallId : " + ((*conflist)[i]).callid << endl; } } /*** Move a member from pending to connected status*/void ConferenceControl::pendingToConnected(string memberid) { //find member in the pending list and remove it int i = 0; bool done = false; while ((!done) && (i < pendingList.size() ) ) { if (pendingList[i].callid == memberid) { connectedList.push_back(pendingList[i]); pendingList.remove(i); done = true; } i++; } assert(done==true); }void ConferenceControl::removeMember(string memberid) { //find member in the pending list and remove it int i = 0; bool done = false; //printList(&pendingList); //cerr<<"callid "+memberid<<endl; while ((!done) && (i < pendingList.size() ) ) { if (pendingList[i].callid == memberid) { pendingList.remove(i); done = true; } i++; } i=0; while ((!done) && (i < connectedList.size() ) ) { if (connectedList[i].callid == memberid) { connectedList.remove(i); done = true; } i++; } //assert(done==true); }/*** Check for new members to connect to*/void ConferenceControl::updateLists(minilist<ConfMember> *conflist) { bool handled = false; for (int i = 0; i < conflist->size(); i++) { string current = (*conflist)[i].uri; //check against pending list for (int j = 0; j < pendingList.size(); j++ ) { if (current == pendingList[j].uri) { handled = true; break; } } //check against connected list if (!handled) { for (int j = 0; j < connectedList.size(); j++ ) { if (current == connectedList[j].uri) { handled = true; break; } } } //if not found in pending or connected list then add to pending list if (!handled&¤t!=(myUri+myDomain)) { //send a connect message to the newly discovered conference members callId = callback->confcb_doConnect(current,confId); current=addDomainToPrefix(current); pendingList.push_back(ConfMember(current, callId ) ); //cerr<<"update pending list=> "+current<<endl; } }} string ConferenceControl::addDomainToPrefix(string remoteUri){ bool done=false; string result=remoteUri; for(unsigned int i=0;i<remoteUri.length();i++) { if(remoteUri[i]=='@'){ done=true; break; } } if(!done) result=remoteUri+myDomain; return result;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -