ue-softphone-sdk 2.1.3 → 2.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/new-index.ts CHANGED
@@ -249,7 +249,7 @@ class ueWebsocket {
249
249
 
250
250
  if (type === "message") {
251
251
  this.ws.on("call", callback);
252
- // this.ws.on("commonEvent", callback);
252
+ this.ws.on("event", callback);
253
253
  // this.ws.on("monitor", callback);
254
254
  }
255
255
  }
@@ -427,7 +427,6 @@ export default class ueSoftphone {
427
427
  loginInfo.data.pushServer,
428
428
  loginInfo.data.agent
429
429
  );
430
- debugger;
431
430
  if (loginType === "WEBRTC") {
432
431
  this.getWebrtcInfo(server, options);
433
432
  }
@@ -567,11 +566,15 @@ export default class ueSoftphone {
567
566
  });
568
567
 
569
568
  this.Socketinstance.on("message", (event: any, fn: Function) => {
570
- if (event.subType === "login" && event.data.eventType === "logout") {
569
+ if (event.subType === "KICK_OFF") {
571
570
  this.Socketinstance.disconnect();
572
- if (ueSoftphone.agentInfo.loginType === "WEBRTC") {
571
+ try {
573
572
  WebPhoneSdk.disconnect();
574
- }
573
+ } catch (error) {}
574
+ callbacks.error({
575
+ type: "accountError",
576
+ error: "您的账号在其他网页登录"
577
+ });
575
578
  }
576
579
  callbacks.message({
577
580
  subtype: event.subType,
@@ -2069,13 +2072,6 @@ export default class ueSoftphone {
2069
2072
  loginNumber = ueSoftphone.agentInfo.webrtcSipNumber;
2070
2073
  }
2071
2074
 
2072
- if (loginNumber === null || loginNumber === undefined) {
2073
- params.fail({
2074
- success: false,
2075
- message: "Please fill in the loginNumber field according to the document"
2076
- });
2077
- return;
2078
- }
2079
2075
  const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
2080
2076
  const query: UpdateLoginTypeParams = {
2081
2077
  loginType: params.loginType,
@@ -2472,394 +2468,4 @@ export default class ueSoftphone {
2472
2468
  }
2473
2469
  };
2474
2470
  };
2475
-
2476
- // private _monitorApi = () => {
2477
- // return {
2478
- // // 监听
2479
- // listen(params: listenParams) {
2480
- // params.success =
2481
- // params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
2482
- // params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
2483
-
2484
- // if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
2485
- // params.fail({
2486
- // success: false,
2487
- // message: "initialization not complete!"
2488
- // });
2489
- // return;
2490
- // }
2491
-
2492
- // if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
2493
- // params.fail({
2494
- // success: false,
2495
- // message: "initialization not complete!"
2496
- // });
2497
- // return;
2498
- // }
2499
- // if (params.agentNumber === null || params.agentNumber === undefined) {
2500
- // params.fail({
2501
- // success: false,
2502
- // message: "Parameter agentNumber is required!"
2503
- // });
2504
- // return;
2505
- // }
2506
-
2507
- // const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
2508
-
2509
- // ueSoftphone.request(server + "/call/sdk/v1/call/transfer/listen", {
2510
- // verb: "POST",
2511
- // body: params,
2512
- // loginToken: ueSoftphone.loginToken,
2513
- // sessionId: ueSoftphone.agentInfo._id,
2514
- // accountId: ueSoftphone.agentInfo.accountId,
2515
- // success: (res: any) => {
2516
- // if (res.success) {
2517
- // (params.success as Function)({
2518
- // success: true,
2519
- // message: "listen success",
2520
- // data: res.data.response.data
2521
- // });
2522
- // } else {
2523
- // (params.fail as Function)({
2524
- // success: false,
2525
- // message: res.message,
2526
- // code: res.code
2527
- // });
2528
- // }
2529
- // }
2530
- // });
2531
- // },
2532
- // // 抢接
2533
- // loot(params: lootParams) {
2534
- // params.success =
2535
- // params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
2536
- // params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
2537
-
2538
- // if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
2539
- // params.fail({
2540
- // success: false,
2541
- // message: "initialization not complete!"
2542
- // });
2543
- // return;
2544
- // }
2545
-
2546
- // if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
2547
- // params.fail({
2548
- // success: false,
2549
- // message: "initialization not complete!"
2550
- // });
2551
- // return;
2552
- // }
2553
- // if (params.agentNumber === null || params.agentNumber === undefined) {
2554
- // params.fail({
2555
- // success: false,
2556
- // message: "Parameter agentNumber is required!"
2557
- // });
2558
- // return;
2559
- // }
2560
-
2561
- // const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
2562
-
2563
- // ueSoftphone.request(server + "/call/sdk/v1/call/transfer/loot", {
2564
- // verb: "POST",
2565
- // body: params,
2566
- // loginToken: ueSoftphone.loginToken,
2567
- // sessionId: ueSoftphone.agentInfo._id,
2568
- // accountId: ueSoftphone.agentInfo.accountId,
2569
- // success: (res: any) => {
2570
- // if (res.success) {
2571
- // (params.success as Function)({
2572
- // success: true,
2573
- // message: "loot success",
2574
- // data: res.data.response.data
2575
- // });
2576
- // } else {
2577
- // (params.fail as Function)({
2578
- // success: false,
2579
- // message: res.message,
2580
- // code: res.code
2581
- // });
2582
- // }
2583
- // }
2584
- // });
2585
- // },
2586
- // // 耳语
2587
- // whisper(params: whisperParams) {
2588
- // params.success =
2589
- // params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
2590
- // params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
2591
-
2592
- // if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
2593
- // params.fail({
2594
- // success: false,
2595
- // message: "initialization not complete!"
2596
- // });
2597
- // return;
2598
- // }
2599
-
2600
- // if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
2601
- // params.fail({
2602
- // success: false,
2603
- // message: "initialization not complete!"
2604
- // });
2605
- // return;
2606
- // }
2607
- // if (params.agentNumber === null || params.agentNumber === undefined) {
2608
- // params.fail({
2609
- // success: false,
2610
- // message: "Parameter agentNumber is required!"
2611
- // });
2612
- // return;
2613
- // }
2614
-
2615
- // const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
2616
-
2617
- // ueSoftphone.request(server + "/call/sdk/v1/call/transfer/whisper", {
2618
- // verb: "POST",
2619
- // body: params,
2620
- // loginToken: ueSoftphone.loginToken,
2621
- // sessionId: ueSoftphone.agentInfo._id,
2622
- // accountId: ueSoftphone.agentInfo.accountId,
2623
- // success: (res: any) => {
2624
- // if (res.success) {
2625
- // (params.success as Function)({
2626
- // success: true,
2627
- // message: "whisper success",
2628
- // data: res.data.response.data
2629
- // });
2630
- // } else {
2631
- // (params.fail as Function)({
2632
- // success: false,
2633
- // message: res.message,
2634
- // code: res.code
2635
- // });
2636
- // }
2637
- // }
2638
- // });
2639
- // },
2640
- // // 强插
2641
- // breakin(params: breakinParams) {
2642
- // params.success =
2643
- // params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
2644
- // params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
2645
-
2646
- // if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
2647
- // params.fail({
2648
- // success: false,
2649
- // message: "initialization not complete!"
2650
- // });
2651
- // return;
2652
- // }
2653
-
2654
- // if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
2655
- // params.fail({
2656
- // success: false,
2657
- // message: "initialization not complete!"
2658
- // });
2659
- // return;
2660
- // }
2661
- // if (params.agentNumber === null || params.agentNumber === undefined) {
2662
- // params.fail({
2663
- // success: false,
2664
- // message: "Parameter agentNumber is required!"
2665
- // });
2666
- // return;
2667
- // }
2668
-
2669
- // const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
2670
-
2671
- // ueSoftphone.request(server + "/call/sdk/v1/call/transfer/breakin", {
2672
- // verb: "POST",
2673
- // body: params,
2674
- // loginToken: ueSoftphone.loginToken,
2675
- // sessionId: ueSoftphone.agentInfo._id,
2676
- // accountId: ueSoftphone.agentInfo.accountId,
2677
- // success: (res: any) => {
2678
- // if (res.success) {
2679
- // (params.success as Function)({
2680
- // success: true,
2681
- // message: "breakin success",
2682
- // data: res.data.response.data
2683
- // });
2684
- // } else {
2685
- // (params.fail as Function)({
2686
- // success: false,
2687
- // message: res.message,
2688
- // code: res.code
2689
- // });
2690
- // }
2691
- // }
2692
- // });
2693
- // },
2694
- // // 强拆
2695
- // forcedHangup(params: forcedHangupParams) {
2696
- // params.success =
2697
- // params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
2698
- // params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
2699
-
2700
- // if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
2701
- // params.fail({
2702
- // success: false,
2703
- // message: "initialization not complete!"
2704
- // });
2705
- // return;
2706
- // }
2707
-
2708
- // if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
2709
- // params.fail({
2710
- // success: false,
2711
- // message: "initialization not complete!"
2712
- // });
2713
- // return;
2714
- // }
2715
- // if (params.agentNumber === null || params.agentNumber === undefined) {
2716
- // params.fail({
2717
- // success: false,
2718
- // message: "Parameter agentNumber is required!"
2719
- // });
2720
- // return;
2721
- // }
2722
-
2723
- // const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
2724
-
2725
- // ueSoftphone.request(server + "/call/sdk/v1/call/transfer/hangup", {
2726
- // verb: "POST",
2727
- // body: params,
2728
- // loginToken: ueSoftphone.loginToken,
2729
- // sessionId: ueSoftphone.agentInfo._id,
2730
- // accountId: ueSoftphone.agentInfo.accountId,
2731
- // success: (res: any) => {
2732
- // if (res.success) {
2733
- // (params.success as Function)({
2734
- // success: true,
2735
- // message: "forcedHangup success",
2736
- // data: res.data.response.data
2737
- // });
2738
- // } else {
2739
- // (params.fail as Function)({
2740
- // success: false,
2741
- // message: res.message,
2742
- // code: res.code
2743
- // });
2744
- // }
2745
- // }
2746
- // });
2747
- // },
2748
- // // 签入
2749
- // signin(params: signinParams) {
2750
- // params.success =
2751
- // params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
2752
- // params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
2753
-
2754
- // if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
2755
- // params.fail({
2756
- // success: false,
2757
- // message: "initialization not complete!"
2758
- // });
2759
- // return;
2760
- // }
2761
-
2762
- // if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
2763
- // params.fail({
2764
- // success: false,
2765
- // message: "initialization not complete!"
2766
- // });
2767
- // return;
2768
- // }
2769
- // if (params.agentNumber === null || params.agentNumber === undefined) {
2770
- // params.fail({
2771
- // success: false,
2772
- // message: "Parameter agentNumber is required!"
2773
- // });
2774
- // return;
2775
- // }
2776
- // if (params.loginType === null || params.loginType === undefined) {
2777
- // params.fail({
2778
- // success: false,
2779
- // message: "Parameter loginType is required!"
2780
- // });
2781
- // return;
2782
- // }
2783
-
2784
- // const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
2785
-
2786
- // ueSoftphone.request(server + "/call/sdk/v1/call/transfer/signin", {
2787
- // verb: "POST",
2788
- // body: params,
2789
- // loginToken: ueSoftphone.loginToken,
2790
- // sessionId: ueSoftphone.agentInfo._id,
2791
- // accountId: ueSoftphone.agentInfo.accountId,
2792
- // success: (res: any) => {
2793
- // if (res.success) {
2794
- // (params.success as Function)({
2795
- // success: true,
2796
- // message: "signin success",
2797
- // data: res.data.response.data
2798
- // });
2799
- // } else {
2800
- // (params.fail as Function)({
2801
- // success: false,
2802
- // message: res.message,
2803
- // code: res.code
2804
- // });
2805
- // }
2806
- // }
2807
- // });
2808
- // },
2809
- // // 签出
2810
- // signout(params: signoutParams) {
2811
- // params.success =
2812
- // params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
2813
- // params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
2814
-
2815
- // if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
2816
- // params.fail({
2817
- // success: false,
2818
- // message: "initialization not complete!"
2819
- // });
2820
- // return;
2821
- // }
2822
-
2823
- // if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
2824
- // params.fail({
2825
- // success: false,
2826
- // message: "initialization not complete!"
2827
- // });
2828
- // return;
2829
- // }
2830
- // if (params.agentNumber === null || params.agentNumber === undefined) {
2831
- // params.fail({
2832
- // success: false,
2833
- // message: "Parameter agentNumber is required!"
2834
- // });
2835
- // return;
2836
- // }
2837
-
2838
- // const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
2839
-
2840
- // ueSoftphone.request(server + "/call/sdk/v1/call/transfer/signout", {
2841
- // verb: "POST",
2842
- // body: params,
2843
- // loginToken: ueSoftphone.loginToken,
2844
- // sessionId: ueSoftphone.agentInfo._id,
2845
- // accountId: ueSoftphone.agentInfo.accountId,
2846
- // success: (res: any) => {
2847
- // if (res.success) {
2848
- // (params.success as Function)({
2849
- // success: true,
2850
- // message: "signout success",
2851
- // data: res.data.response.data
2852
- // });
2853
- // } else {
2854
- // (params.fail as Function)({
2855
- // success: false,
2856
- // message: res.message,
2857
- // code: res.code
2858
- // });
2859
- // }
2860
- // }
2861
- // });
2862
- // }
2863
- // };
2864
- // };
2865
2471
  }
@@ -25,7 +25,6 @@ export default class WebPhoneSdk {
25
25
  public static message: ((arg0: any) => void | undefined) | undefined
26
26
 
27
27
  constructor (options: Options) {
28
- console.log(options, 'options====')
29
28
  this.options = options
30
29
  WebPhoneSdk.WebrtcObj = new UEInitWebRtc(options)
31
30
  WebPhoneSdk.WebrtcObj.message = (message: any) => {
package/src/webrtc.ts CHANGED
@@ -97,7 +97,7 @@ export default class UEWebrtc {
97
97
 
98
98
  const userAgentDelegate: UserAgentDelegate = {
99
99
  onInvite: (invitation: Invitation): void => {
100
- console.log('userAgent invitation', invitation)
100
+ // console.log('userAgent invitation', invitation)
101
101
  this.Ginvitation = invitation
102
102
  // An Invitation is a Session
103
103
  const incomingSession: Session = invitation
@@ -105,7 +105,7 @@ export default class UEWebrtc {
105
105
  incomingSession.delegate = {
106
106
  // Handle incoming REFER request.
107
107
  onRefer (referral: Referral): void {
108
- console.log(referral)
108
+ // console.log(referral)
109
109
  }
110
110
  };
111
111
  this.sendMessage('incomingcall')
@@ -159,20 +159,19 @@ export default class UEWebrtc {
159
159
  }
160
160
  },
161
161
  onConnect: () => {
162
- console.log('onConnect==============')
162
+ // console.log('onConnect==============')
163
163
  },
164
164
  onDisconnect: () => {
165
- console.log('onDISCONNECT===============')
165
+ // console.log('onDISCONNECT===============')
166
166
  },
167
167
  onRegisterRequest: () => {
168
- console.log('onRegisterRequest===============')
168
+ // console.log('onRegisterRequest===============')
169
169
  },
170
170
  onRegister: () => {
171
- console.log('onRegister=============')
171
+ // console.log('onRegister=============')
172
172
  },
173
173
  onMessage: (message: any) => {
174
- console.log(message)
175
- console.log('onMessage===============')
174
+ // console.log('onMessage===============')
176
175
  }
177
176
  }
178
177
 
@@ -181,6 +180,7 @@ export default class UEWebrtc {
181
180
  throw new Error('Failed to create URI');
182
181
  }
183
182
  const userAgentOptions: UserAgentOptions = {
183
+ logBuiltinEnabled: false,
184
184
  delegate: userAgentDelegate,
185
185
  displayName: 'webrtc',
186
186
  uri,
@@ -190,7 +190,7 @@ export default class UEWebrtc {
190
190
  /* ... */
191
191
  };
192
192
  this.userAgent = new UserAgent(userAgentOptions);
193
- console.log(this.userAgent, 'this.userAgent=====')
193
+ // console.log(this.userAgent, 'this.userAgent=====')
194
194
  const registererOptions: RegistererOptions = {
195
195
  expires: 10
196
196
  }
@@ -201,26 +201,26 @@ export default class UEWebrtc {
201
201
  */
202
202
  const requestDelegate: Core.OutgoingRequestDelegate = {
203
203
  onAccept: (response: Core.IncomingResponse): void => {
204
- console.log('onAccept.....', response)
204
+ // console.log('onAccept.....', response)
205
205
  },
206
206
  onProgress: (response: Core.IncomingResponse): void => {
207
- console.log('onProgress.....', response)
207
+ // console.log('onProgress.....', response)
208
208
  },
209
209
  onRedirect: (response: Core.IncomingResponse): void => {
210
- console.log('onRedirect.....', response)
210
+ // console.log('onRedirect.....', response)
211
211
  },
212
212
  onReject: (response: Core.IncomingResponse): void => {
213
- console.log('onReject.....', response)
213
+ // console.log('onReject.....', response)
214
214
  },
215
215
  onTrying: (response: Core.IncomingResponse): void => {
216
- console.log('onTrying.....', response)
216
+ // console.log('onTrying.....', response)
217
217
  }
218
218
  }
219
219
 
220
220
  const registererRegisterOptions: RegistererRegisterOptions = {
221
221
  requestDelegate
222
222
  }
223
- console.log(registererRegisterOptions, 'registererRegisterOptions===')
223
+ // console.log(registererRegisterOptions, 'registererRegisterOptions===')
224
224
  this.registerHandle(registererRegisterOptions)
225
225
  }
226
226