コード例 #1
0
ファイル: Form1.cs プロジェクト: shizenghua/TSAPIDemo
        private void deflectCallButton_Click(object sender, EventArgs e)
        {
            if (!streamCheckbox.Checked || deviceTextBox.Text.Length == 0 || deviceTextBox.Text.Length > 5 || !streamCheckbox.Checked) { return; }
            Csta.ConnectionID_t[] conns = GetCurrentConnections(this.deviceTextBox.Text);

            if (conns == null || conns.Length == 0)
            {
                MessageBox.Show("No active calls");
                return;
            }
            var invokeId = new Acs.InvokeID_t();

            var deviceSelectDialog = new DeviceSelectPopupForm();
            deviceSelectDialog.ShowDialog();
            DialogResult deviceSelectResult = deviceSelectDialog.DialogResult;
            if (deviceSelectResult != DialogResult.OK)
            {
                //MessageBox.Show("No device selected");
                return;
            }
            Csta.DeviceID_t calledDevice = deviceSelectDialog.deviceIdTextBox.Text;

            Acs.RetCode_t retCode = Csta.cstaDeflectCall(this.acsHandle, invokeId, conns[0], ref calledDevice, null);
            Debug.WriteLine("cstaDeflectCall result = " + retCode._value);

            var evtBuf = new Csta.EventBuffer_t();
            ushort eventBufSize = Csta.CSTA_MAX_HEAP;
            ushort numEvents;
            retCode = Acs.acsGetEventBlock(this.acsHandle,
                                          evtBuf,
                                          ref eventBufSize,
                                          privData,
                                          out numEvents);
            if (evtBuf.evt.eventHeader.eventClass.eventClass == Csta.CSTACONFIRMATION && evtBuf.evt.eventHeader.eventType.eventType == Csta.CSTA_DEFLECT_CALL_CONF)
            {
                MessageBox.Show("cstaDeflectCall Succeded");
            }
            else
            {
                MessageBox.Show("cstaDeflectCall Failed. Error was: " + evtBuf.evt.cstaConfirmation.universalFailure.error);
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: shizenghua/TSAPIDemo
        private void attSingleStepTransferCallButton_Click(object sender, EventArgs e)
        {
            if (!streamCheckbox.Checked || deviceTextBox.Text.Length == 0 || deviceTextBox.Text.Length > 5 || !streamCheckbox.Checked) { return; }
            Csta.DeviceID_t currentDevice = deviceTextBox.Text;
            Csta.ConnectionID_t[] conns = GetCurrentConnections(this.deviceTextBox.Text);

            if (conns == null || conns.Length == 0)
            {
                MessageBox.Show("No active calls");
                return;
            }

            var devicePopup = new DeviceSelectPopupForm();
            devicePopup._parent = this;
            var dialogResult = devicePopup.ShowDialog();
            if (dialogResult != DialogResult.OK) return;
            Csta.DeviceID_t transferredTo = devicePopup.deviceIdTextBox.Text;
            var activeCall = conns[0];

            Acs.RetCode_t retCode = Att.attSingleStepTransferCall(this.privData, activeCall, ref transferredTo);
            Log("attSingleStepTransferCall result = " + retCode._value);

            if (retCode._value < 0) return;
            var invokeId = new Acs.InvokeID_t();
            retCode = Csta.cstaEscapeService(this.acsHandle, invokeId, this.privData);

            if (retCode._value < 0)
            {
                this.Log("cstaEscapeService result = " + retCode._value);
                return;
            }

            ushort eventBufferSize = Csta.CSTA_MAX_HEAP;
            this.privData.length = Att.ATT_MAX_PRIVATE_DATA;
            var eventBuf = new Csta.EventBuffer_t();
            ushort numEvents;
            retCode = Acs.acsGetEventBlock(this.acsHandle, eventBuf, ref eventBufferSize, this.privData, out numEvents);
            this.Log("acsGetEventBlock result = " + retCode._value);
            if (retCode._value < 0) return;

            if (eventBuf.evt.eventHeader.eventClass.eventClass == Csta.CSTACONFIRMATION && eventBuf.evt.eventHeader.eventType.eventType == Csta.CSTA_ESCAPE_SVC_CONF)
            {
                Att.ATTEvent_t attEvt = new Att.ATTEvent_t();
                retCode = Att.attPrivateData(this.privData, attEvt);
                Debug.WriteLine("attPrivateData retCode = " + retCode._value);
                if (attEvt.eventType.eventType == Att.ATT_SINGLE_STEP_TRANSFER_CALL_CONF)
                    MessageBox.Show("attSingleStepTransfer Succeded. New device = " + attEvt.ssTransferCallConf.transferredCall.deviceID);
                else
                    MessageBox.Show("Got wrong ATT Event... " + attEvt.eventType.eventType);
            }
            else
            {
                MessageBox.Show("attSingleStepConference Failed. Error was: " + eventBuf.evt.cstaConfirmation.universalFailure.error);
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: shizenghua/TSAPIDemo
        private void cstaMakePredictiveCallButton_Click(object sender, EventArgs e)
        {
            if (!streamCheckbox.Checked || deviceTextBox.Text.Length == 0 || deviceTextBox.Text.Length > 5 || !streamCheckbox.Checked) { return; }

            var invokeId = new Acs.InvokeID_t();
            Csta.DeviceID_t callingDevice = this.deviceTextBox.Text;
            DeviceSelectPopupForm deviceSelect = new DeviceSelectPopupForm();
            DialogResult deviceSelectDialog = deviceSelect.ShowDialog();
            if (deviceSelectDialog != DialogResult.OK) return;

            Csta.DeviceID_t calledDevice = deviceSelect.deviceIdTextBox.Text;
            var u2uString = "Hello, I AM test u2u string";
            var u2uInfo = new Att.ATTUserToUserInfo_t();
            // fixed u2u size
            int u2uSize = Att.ATT_MAX_UUI_SIZE;
            u2uInfo.length = (short)u2uString.Length;
            u2uInfo.type = Att.ATTUUIProtocolType_t.UUI_IA5_ASCII;
            u2uInfo.value = Encoding.ASCII.GetBytes(u2uString);
            Array.Resize(ref u2uInfo.value, u2uSize);
            Att.ATTAnswerTreat_t at = Att.ATTAnswerTreat_t.AT_NONE;
            var dummyDev = new Csta.DeviceID_t();

            Att.attV6MakePredictiveCall(this.privData, false, 2, at, ref dummyDev, ref u2uInfo);

            Csta.AllocationState_t allocState = Csta.AllocationState_t.AS_CALL_ESTABLISHED;
            Acs.RetCode_t retCode = Csta.cstaMakePredictiveCall(this.acsHandle, invokeId, ref callingDevice, ref calledDevice, allocState, this.privData);
            Debug.WriteLine("cstaMakePredictiveCall result = " + retCode._value);

            var evtBuf = new Csta.EventBuffer_t();
            ushort eventBufSize = Csta.CSTA_MAX_HEAP;
            ushort numEvents;
            retCode = Acs.acsGetEventBlock(this.acsHandle,
                                          evtBuf,
                                          ref eventBufSize,
                                          privData,
                                          out numEvents);
            if (evtBuf.evt.eventHeader.eventClass.eventClass == Csta.CSTACONFIRMATION && evtBuf.evt.eventHeader.eventType.eventType == Csta.CSTA_MAKE_PREDICTIVE_CALL_CONF)
            {
                Att.ATTEvent_t attEvt = new Att.ATTEvent_t();
                retCode = Att.attPrivateData(this.privData, attEvt);
                Debug.WriteLine("attPrivateData retCode = " + retCode._value);
                if (attEvt.eventType.eventType == Att.ATT_MAKE_PREDICTIVE_CALL_CONF)
                    MessageBox.Show(String.Format("Make Predictive Call from {0} to {1} is successfull! Ucid of new call = {2}", callingDevice.ToString(), calledDevice.ToString(), attEvt.makePredictiveCall.ucid));
                else
                    MessageBox.Show("Got wrong ATT Event... " + attEvt.eventType.eventType);

                MessageBox.Show("cstaMakePredictiveCall Succeded");
            }
            else
            {
                MessageBox.Show("cstaMakePredictiveCall Failed. Error was: " + evtBuf.evt.cstaConfirmation.universalFailure.error);
            }
        }