Index: remoting/protocol/client_event_dispatcher.cc |
diff --git a/remoting/protocol/client_event_dispatcher.cc b/remoting/protocol/client_event_dispatcher.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..60c5d43e9383b43fd23df5f54ee9d0ae77a52858 |
--- /dev/null |
+++ b/remoting/protocol/client_event_dispatcher.cc |
@@ -0,0 +1,49 @@ |
+// 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_event_dispatcher.h" |
+ |
+#include "base/message_loop_proxy.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 { |
+ |
+ClientEventDispatcher::ClientEventDispatcher() |
+ : writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) { |
+} |
+ |
+ClientEventDispatcher::~ClientEventDispatcher() { |
+ writer_->Close(); |
+} |
+ |
+void ClientEventDispatcher::Init(Session* session) { |
+ DCHECK(session); |
+ |
+ // TODO(garykac): Set write failed callback. |
+ writer_->Init(session->event_channel(), |
+ BufferedSocketWriter::WriteFailedCallback()); |
+} |
+ |
+void ClientEventDispatcher::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 ClientEventDispatcher::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()); |
+} |
+ |
+} // namespace protocol |
+} // namespace remoting |