OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 } | 355 } |
356 | 356 |
357 if (!socket_->Read(bytes, sizeof(bytes), &bytes_read)) { | 357 if (!socket_->Read(bytes, sizeof(bytes), &bytes_read)) { |
358 // TODO: deal with error information | 358 // TODO: deal with error information |
359 return; | 359 return; |
360 } | 360 } |
361 | 361 |
362 if (bytes_read == 0) | 362 if (bytes_read == 0) |
363 return; | 363 return; |
364 | 364 |
365 //#ifdef _DEBUG | 365 //#if !defined(NDEBUG) |
366 client_->SignalLogInput(bytes, static_cast<int>(bytes_read)); | 366 client_->SignalLogInput(bytes, static_cast<int>(bytes_read)); |
367 //#endif | 367 //#endif |
368 | 368 |
369 engine_->HandleInput(bytes, bytes_read); | 369 engine_->HandleInput(bytes, bytes_read); |
370 } | 370 } |
371 } | 371 } |
372 | 372 |
373 void XmppClient::Private::OnSocketClosed() { | 373 void XmppClient::Private::OnSocketClosed() { |
374 int code = socket_->GetError(); | 374 int code = socket_->GetError(); |
375 engine_->ConnectionClosed(code); | 375 engine_->ConnectionClosed(code); |
376 } | 376 } |
377 | 377 |
378 void XmppClient::Private::OnStateChange(int state) { | 378 void XmppClient::Private::OnStateChange(int state) { |
379 if (state == XmppEngine::STATE_CLOSED) { | 379 if (state == XmppEngine::STATE_CLOSED) { |
380 client_->EnsureClosed(); | 380 client_->EnsureClosed(); |
381 } | 381 } |
382 else { | 382 else { |
383 client_->SignalStateChange((XmppEngine::State)state); | 383 client_->SignalStateChange((XmppEngine::State)state); |
384 } | 384 } |
385 client_->Wake(); | 385 client_->Wake(); |
386 } | 386 } |
387 | 387 |
388 void XmppClient::Private::WriteOutput(const char* bytes, size_t len) { | 388 void XmppClient::Private::WriteOutput(const char* bytes, size_t len) { |
389 //#ifdef _DEBUG | 389 //#if !defined(NDEBUG) |
390 client_->SignalLogOutput(bytes, static_cast<int>(len)); | 390 client_->SignalLogOutput(bytes, static_cast<int>(len)); |
391 //#endif | 391 //#endif |
392 | 392 |
393 socket_->Write(bytes, len); | 393 socket_->Write(bytes, len); |
394 // TODO: deal with error information | 394 // TODO: deal with error information |
395 } | 395 } |
396 | 396 |
397 void XmppClient::Private::StartTls(const std::string& domain) { | 397 void XmppClient::Private::StartTls(const std::string& domain) { |
398 #if defined(FEATURE_ENABLE_SSL) | 398 #if defined(FEATURE_ENABLE_SSL) |
399 socket_->StartTls(domain); | 399 socket_->StartTls(domain); |
(...skipping 15 matching lines...) Expand all Loading... |
415 void XmppClient::EnsureClosed() { | 415 void XmppClient::EnsureClosed() { |
416 if (!d_->signal_closed_) { | 416 if (!d_->signal_closed_) { |
417 d_->signal_closed_ = true; | 417 d_->signal_closed_ = true; |
418 delivering_signal_ = true; | 418 delivering_signal_ = true; |
419 SignalStateChange(XmppEngine::STATE_CLOSED); | 419 SignalStateChange(XmppEngine::STATE_CLOSED); |
420 delivering_signal_ = false; | 420 delivering_signal_ = false; |
421 } | 421 } |
422 } | 422 } |
423 | 423 |
424 } // namespace buzz | 424 } // namespace buzz |
OLD | NEW |