00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 #pragma once 00012 00013 #include "builtin_server_addon.h" 00014 #include "builtin_server.h" 00015 00016 #include <opc/ua/connection_listener.h> 00017 00018 #include <opc/common/addons_core/addon.h> 00019 #include <opc/common/thread.h> 00020 #include <opc/ua/client/binary_client.h> 00021 #include <src/server/opcua_protocol.h> 00022 00023 #include <atomic> 00024 #include <condition_variable> 00025 #include <mutex> 00026 #include <thread> 00027 00028 00029 namespace OpcUa 00030 { 00031 namespace Impl 00032 { 00033 class BufferedInput; 00034 00035 class BuiltinServerAddon 00036 : public Common::Addon 00037 , public Server::TcpServer 00038 , public Server::BuiltinServer 00039 , private Common::ThreadObserver 00040 { 00041 public: 00042 BuiltinServerAddon(); 00043 ~BuiltinServerAddon(); 00044 00045 OpcUa::Services::SharedPtr GetServices() const override; 00046 00047 public: // Common::Addon 00048 virtual void Initialize(Common::AddonsManager& addons, const Common::AddonParameters& params); 00049 virtual void Stop(); 00050 00051 public: // TcpServer 00052 virtual void Listen(const OpcUa::Server::TcpParameters& params, std::shared_ptr<OpcUa::Server::IncomingConnectionProcessor> processor); 00053 virtual void StopListen(const OpcUa::Server::TcpParameters& params); 00054 00055 private: 00056 virtual void OnSuccess(); 00057 virtual void OnError(const std::exception& exc); 00058 00059 private: 00060 std::shared_ptr<BufferedInput> ClientInput; 00061 std::shared_ptr<BufferedInput> ServerInput; 00062 00063 std::shared_ptr<OpcUa::IOChannel> ClientChannel; 00064 std::shared_ptr<OpcUa::IOChannel> ServerChannel; 00065 std::unique_ptr<Common::Thread> Thread; 00066 00067 OpcUa::Server::OpcUaProtocol::SharedPtr Protocol; 00068 bool Debug; 00069 }; 00070 00071 } // namespace Impl 00072 } // namespace OpcUa