urasoft-live-support 1.1.9 → 1.1.12

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/dist/index.d.ts CHANGED
@@ -40,6 +40,8 @@ interface SignalRConfig {
40
40
  sendMethodName?: string;
41
41
  receiveMethodName?: string;
42
42
  transport?: 'WebSockets' | 'ServerSentEvents' | 'LongPolling' | 'All';
43
+ skipNegotiation?: boolean;
44
+ withCredentials?: boolean;
43
45
  logLevel?: 'Trace' | 'Debug' | 'Information' | 'Warning' | 'Error' | 'Critical' | 'None';
44
46
  reconnect?: SignalRReconnectOptions;
45
47
  onConnected?: (connectionId?: string) => void;
@@ -164,6 +166,8 @@ declare class SignalRClient {
164
166
  private reconnectOptions;
165
167
  constructor(config: SignalRConfig);
166
168
  connect(): Promise<void>;
169
+ private initializeConnection;
170
+ private setupEventListeners;
167
171
  private getTransportType;
168
172
  private getLogLevel;
169
173
  private calculateRetryDelay;
package/dist/index.esm.js CHANGED
@@ -3380,7 +3380,6 @@ class SignalRClient {
3380
3380
  // Hub URL'ini query parametreleri ile birleştir
3381
3381
  let finalHubUrl = this.config.hubUrl;
3382
3382
  console.log('SignalR connect() - Initial hubUrl:', this.config.hubUrl);
3383
- console.log('SignalR connect() - queryParams:', this.config.queryParams);
3384
3383
  if (this.config.queryParams) {
3385
3384
  const queryString = new URLSearchParams(this.config.queryParams).toString();
3386
3385
  if (queryString) {
@@ -3388,16 +3387,39 @@ class SignalRClient {
3388
3387
  finalHubUrl = this.config.hubUrl + separator + queryString;
3389
3388
  }
3390
3389
  }
3391
- console.log('SignalR connect() - Final hubUrl being passed to withUrl():', finalHubUrl);
3392
- console.log('SignalR connect() - Transport type:', transportType);
3393
- console.log('SignalR connect() - Headers:', this.config.headers);
3394
- console.log('SignalR connect() - accessTokenFactory:', this.config.accessTokenFactory);
3390
+ console.log('SignalR connect() - Final hubUrl:', finalHubUrl);
3391
+ // skipNegotiation sadece WebSockets ile kullanılabilir
3392
+ const skipNegotiation = !!(this.config.skipNegotiation && this.config.transport === 'WebSockets');
3393
+ try {
3394
+ await this.initializeConnection(finalHubUrl, transportType, logLevel, skipNegotiation);
3395
+ }
3396
+ catch (error) {
3397
+ // Eğer skipNegotiation açıksa ve bağlantı başarısız olduysa (özellikle 400 Bad Request gibi),
3398
+ // negotiate ile tekrar dene
3399
+ if (skipNegotiation) {
3400
+ console.warn('Initial connection with skipNegotiation failed. Retrying with negotiation enabled...');
3401
+ try {
3402
+ await this.initializeConnection(finalHubUrl, transportType, logLevel, false);
3403
+ return;
3404
+ }
3405
+ catch (retryError) {
3406
+ console.error('Retry with negotiation also failed:', retryError);
3407
+ // Orijinal hatayı fırlat
3408
+ throw error;
3409
+ }
3410
+ }
3411
+ throw error;
3412
+ }
3413
+ }
3414
+ async initializeConnection(url, transportType, logLevel, skipNegotiation) {
3395
3415
  // Hub connection builder'ı tek withUrl çağrısı ile oluştur
3396
3416
  const builder = new HubConnectionBuilder()
3397
- .withUrl(finalHubUrl, {
3417
+ .withUrl(url, {
3398
3418
  transport: transportType,
3399
3419
  headers: this.config.headers,
3400
3420
  accessTokenFactory: this.config.accessTokenFactory,
3421
+ skipNegotiation: skipNegotiation,
3422
+ withCredentials: this.config.withCredentials ?? false,
3401
3423
  })
3402
3424
  .configureLogging(logLevel);
3403
3425
  // Otomatik yeniden bağlanmayı ayarla
@@ -3421,7 +3443,27 @@ class SignalRClient {
3421
3443
  });
3422
3444
  }
3423
3445
  this.connection = builder.build();
3424
- // Event listeners
3446
+ // Event listener'ları ekle
3447
+ this.setupEventListeners();
3448
+ try {
3449
+ await this.connection.start();
3450
+ console.log('SignalR connected');
3451
+ this.reconnectAttempts = 0;
3452
+ if (this.config.onConnected) {
3453
+ this.config.onConnected(this.connection.connectionId || undefined);
3454
+ }
3455
+ }
3456
+ catch (error) {
3457
+ console.error('SignalR connection error details:', error);
3458
+ if (this.config.onError) {
3459
+ this.config.onError(error);
3460
+ }
3461
+ throw error;
3462
+ }
3463
+ }
3464
+ setupEventListeners() {
3465
+ if (!this.connection)
3466
+ return;
3425
3467
  this.connection.onclose((error) => {
3426
3468
  console.log('SignalR connection closed', error);
3427
3469
  if (this.config.onDisconnected) {
@@ -3451,21 +3493,6 @@ class SignalRClient {
3451
3493
  this.config.onMessageReceived(message);
3452
3494
  }
3453
3495
  });
3454
- try {
3455
- await this.connection.start();
3456
- console.log('SignalR connected');
3457
- this.reconnectAttempts = 0;
3458
- if (this.config.onConnected) {
3459
- this.config.onConnected(this.connection.connectionId || undefined);
3460
- }
3461
- }
3462
- catch (error) {
3463
- console.error('SignalR connection error:', error);
3464
- if (this.config.onError) {
3465
- this.config.onError(error);
3466
- }
3467
- throw error;
3468
- }
3469
3496
  }
3470
3497
  getTransportType() {
3471
3498
  const transport = this.config.transport || 'All';