X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fnetwork%2Fstream_socket_transport.h;fp=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fnetwork%2Fstream_socket_transport.h;h=587ffbbd69cdb71cdb6f898a522f0c404125369c;hb=e26c1ec581be598521517829adba8c8dd23a768f;hp=0000000000000000000000000000000000000000;hpb=6699c1aea74eeb0eb400e6299079f0c7576f716f;p=iec.git diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/network/stream_socket_transport.h b/src/type3_AndroidCloud/anbox-master/src/anbox/network/stream_socket_transport.h new file mode 100644 index 0000000..587ffbb --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/network/stream_socket_transport.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_STREAM_SOCKET_TRANSPORT_H_ +#define ANBOX_STREAM_SOCKET_TRANSPORT_H_ + +#include "anbox/common/fd.h" +#include "anbox/network/socket_messenger.h" +#include "anbox/runtime.h" + +#include + +#include + +namespace anbox { +namespace network { +class StreamSocketTransport { + public: + class Observer { + public: + Observer() = default; + virtual ~Observer() = default; + + virtual void on_data_available() = 0; + virtual void on_disconnected() = 0; + + Observer(Observer const&) = delete; + Observer& operator=(Observer const&) = delete; + }; + + StreamSocketTransport(const std::string& socket_path, + const std::shared_ptr& rt); + + void register_observer(std::shared_ptr const& observer_); + void unregister_observer(std::shared_ptr const& observer_); + + void send_message(std::vector const& buffer); + void read_next_message(); + + private: + void on_read_size(const boost::system::error_code& ec, + std::size_t bytes_read); + + std::shared_ptr observer_; + std::shared_ptr socket_; + SocketMessenger messenger_; +}; +} // namespace network +} // namespace anbox + +#endif // STREAM_SOCKET_TRANSPORT_H_