Index: remoting/protocol/client_input_dispatcher.cc |
diff --git a/remoting/protocol/client_input_dispatcher.cc b/remoting/protocol/client_input_dispatcher.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4c9f54783f0a2da222534884500d4e113a627fba |
--- /dev/null |
+++ b/remoting/protocol/client_input_dispatcher.cc |
@@ -0,0 +1,53 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "remoting/protocol/client_input_dispatcher.h" |
+ |
+#include "base/time.h" |
+#include "remoting/proto/event.pb.h" |
+#include "remoting/proto/internal.pb.h" |
+#include "remoting/protocol/buffered_socket_writer.h" |
+#include "remoting/protocol/session.h" |
+#include "remoting/protocol/util.h" |
+ |
+namespace remoting { |
+namespace protocol { |
+ |
+ClientInputDispatcher::ClientInputDispatcher( |
+ base::MessageLoopProxy* message_loop) |
+ : writer_(new BufferedSocketWriter(message_loop)) { |
+} |
+ |
+ClientInputDispatcher::~ClientInputDispatcher() { |
+ Close(); |
+} |
+ |
+void ClientInputDispatcher::Init(Session* session) { |
+ DCHECK(session); |
+ |
+ // TODO(garykac) Set write failed callback. |
Wez
2011/11/17 01:51:56
This TODO applies equally to the ClientControlDisp
Sergey Ulanov
2011/11/17 19:29:06
Done.
|
+ writer_->Init(session->event_channel(), |
+ BufferedSocketWriter::WriteFailedCallback()); |
+} |
+ |
+void ClientInputDispatcher::InjectKeyEvent(const KeyEvent& event) { |
+ EventMessage message; |
+ message.set_sequence_number(base::Time::Now().ToInternalValue()); |
+ message.mutable_key_event()->CopyFrom(event); |
+ writer_->Write(SerializeAndFrameMessage(message), base::Closure()); |
+} |
+ |
+void ClientInputDispatcher::InjectMouseEvent(const MouseEvent& event) { |
+ EventMessage message; |
+ message.set_sequence_number(base::Time::Now().ToInternalValue()); |
+ message.mutable_mouse_event()->CopyFrom(event); |
+ writer_->Write(SerializeAndFrameMessage(message), base::Closure()); |
+} |
+ |
+void ClientInputDispatcher::Close() { |
+ writer_->Close(); |
Wez
2011/11/17 01:51:56
Fold this into dtor?
Sergey Ulanov
2011/11/17 19:29:06
Done.
|
+} |
+ |
+} // namespace protocol |
+} // namespace remoting |