test_echo_extension_session.cc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "remoting/host/test_echo_extension_session.h"
  5. #include "base/check.h"
  6. #include "remoting/proto/control.pb.h"
  7. #include "remoting/protocol/client_stub.h"
  8. namespace {
  9. constexpr char kExtensionMessageType[] = "test-echo";
  10. }
  11. namespace remoting {
  12. TestEchoExtensionSession::TestEchoExtensionSession() = default;
  13. TestEchoExtensionSession::~TestEchoExtensionSession() = default;
  14. bool TestEchoExtensionSession::OnExtensionMessage(
  15. ClientSessionDetails* client_session_details,
  16. protocol::ClientStub* client_stub,
  17. const protocol::ExtensionMessage& message) {
  18. DCHECK(client_stub);
  19. if (message.type() != kExtensionMessageType) {
  20. return false;
  21. }
  22. protocol::ExtensionMessage reply;
  23. reply.set_type("test-echo-reply");
  24. if (message.has_data()) {
  25. reply.set_data(message.data().substr(0, 16));
  26. }
  27. client_stub->DeliverHostMessage(reply);
  28. return true;
  29. }
  30. } // namespace remoting