@@ -300,58 +300,58 @@ private IEnumerator ProcessReceiveQueue()
300
300
#region Threaded Functions
301
301
// NOTE: ALl functions in this region are operating in a background thread, do NOT call any Unity functions!
302
302
#if ! NETFX_CORE
303
- private void SendMessages ( )
304
- {
305
- try
306
- {
307
- WebSocket ws = null ;
308
-
309
- ws = new WebSocket ( URL ) ;
310
- // if (Headers != null)
311
- // ws.Headers = Headers;
312
- if ( Authentication != null )
313
- ws . SetCredentials ( Authentication . Username , Authentication . Password , true ) ;
314
- ws . OnOpen += OnWSOpen ;
315
- ws . OnClose += OnWSClose ;
316
- ws . OnError += OnWSError ;
317
- ws . OnMessage += OnWSMessage ;
318
- ws . Connect ( ) ;
319
-
320
- while ( _connectionState == ConnectionState . CONNECTED )
321
- {
322
- _sendEvent . WaitOne ( 50 ) ;
323
-
324
- Message msg = null ;
325
- lock ( _sendQueue )
326
- {
327
- if ( _sendQueue . Count > 0 )
328
- msg = _sendQueue . Dequeue ( ) ;
329
- }
330
-
331
- while ( msg != null )
332
- {
333
- if ( msg is TextMessage )
334
- ws . Send ( ( ( TextMessage ) msg ) . Text ) ;
335
- else if ( msg is BinaryMessage )
336
- ws . Send ( ( ( BinaryMessage ) msg ) . Data ) ;
337
-
338
- msg = null ;
339
- lock ( _sendQueue )
340
- {
341
- if ( _sendQueue . Count > 0 )
342
- msg = _sendQueue . Dequeue ( ) ;
343
- }
344
- }
345
- }
346
-
347
- ws . Close ( ) ;
348
- }
349
- catch ( System . Exception e )
350
- {
351
- _connectionState = ConnectionState . DISCONNECTED ;
352
- Log . Error ( "WSConnector" , "Caught WebSocket exception: {0}" , e . ToString ( ) ) ;
353
- }
354
- }
303
+ private void SendMessages ( )
304
+ {
305
+ try
306
+ {
307
+ WebSocket ws = null ;
308
+
309
+ ws = new WebSocket ( URL ) ;
310
+ if ( Headers != null )
311
+ ws . CustomHeaders = Headers ;
312
+ if ( Authentication != null )
313
+ ws . SetCredentials ( Authentication . Username , Authentication . Password , true ) ;
314
+ ws . OnOpen += OnWSOpen ;
315
+ ws . OnClose += OnWSClose ;
316
+ ws . OnError += OnWSError ;
317
+ ws . OnMessage += OnWSMessage ;
318
+ ws . Connect ( ) ;
319
+
320
+ while ( _connectionState == ConnectionState . CONNECTED )
321
+ {
322
+ _sendEvent . WaitOne ( 50 ) ;
323
+
324
+ Message msg = null ;
325
+ lock ( _sendQueue )
326
+ {
327
+ if ( _sendQueue . Count > 0 )
328
+ msg = _sendQueue . Dequeue ( ) ;
329
+ }
330
+
331
+ while ( msg != null )
332
+ {
333
+ if ( msg is TextMessage )
334
+ ws . Send ( ( ( TextMessage ) msg ) . Text ) ;
335
+ else if ( msg is BinaryMessage )
336
+ ws . Send ( ( ( BinaryMessage ) msg ) . Data ) ;
337
+
338
+ msg = null ;
339
+ lock ( _sendQueue )
340
+ {
341
+ if ( _sendQueue . Count > 0 )
342
+ msg = _sendQueue . Dequeue ( ) ;
343
+ }
344
+ }
345
+ }
346
+
347
+ ws . Close ( ) ;
348
+ }
349
+ catch ( System . Exception e )
350
+ {
351
+ _connectionState = ConnectionState . DISCONNECTED ;
352
+ Log . Error ( "WSConnector" , "Caught WebSocket exception: {0}" , e . ToString ( ) ) ;
353
+ }
354
+ }
355
355
356
356
private void OnWSOpen ( object sender , System . EventArgs e )
357
357
{
0 commit comments