]> git.sesse.net Git - casparcg/commitdiff
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 10 Mar 2012 13:19:46 +0000 (13:19 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 10 Mar 2012 13:19:46 +0000 (13:19 +0000)
protocol/osc/server.cpp
protocol/util/AsyncEventServer.cpp

index 3bdec7fcbcc528875b769d3146841e70cd9f0d43..4204a482820662ae357e3356b692f9f4bd1bbc3a 100644 (file)
@@ -73,14 +73,12 @@ typedef std::set<spl::shared_ptr<connection>> connection_set;
 \r
 class connection : public spl::enable_shared_from_this<connection>\r
 {    \r
-    spl::shared_ptr<tcp::socket>       socket_; \r
-       boost::optional<std::regex>             regex_;\r
+    const spl::shared_ptr<tcp::socket>         socket_; \r
+       const spl::shared_ptr<connection_set>   connection_set_;\r
 \r
-       std::array<char, 8192>                  data_;\r
-       \r
-       spl::shared_ptr<connection_set> connection_set_;\r
-\r
-       std::string                                             input_;\r
+       boost::optional<std::regex>                             regex_;\r
+       std::array<char, 32768>                                 data_;\r
+       std::string                                                             input_;\r
 \r
 public:\r
     static spl::shared_ptr<connection> create(spl::shared_ptr<tcp::socket> socket, spl::shared_ptr<connection_set> connection_set)\r
@@ -147,8 +145,6 @@ private:
                }  \r
                else if (error != boost::asio::error::operation_aborted)                \r
                        stop();         \r
-               else\r
-                       read_some();\r
     }\r
 \r
     void handle_write(const spl::shared_ptr<std::vector<char>>& data, const boost::system::error_code& error, size_t bytes_transferred)\r
index 3821d4a735c27e64644603dce607ece4dc425efb..9587752e690bf7be0f24c3bfdb4b62e761440b02 100644 (file)
@@ -47,15 +47,13 @@ typedef std::set<spl::shared_ptr<connection>> connection_set;
 \r
 class connection : public spl::enable_shared_from_this<connection>, public ClientInfo\r
 {    \r
-    spl::shared_ptr<tcp::socket>                               socket_; \r
+    const spl::shared_ptr<tcp::socket>                 socket_; \r
+       const spl::shared_ptr<connection_set>           connection_set_;\r
        const std::wstring                                                      name_;\r
+       const spl::shared_ptr<IProtocolStrategy>        protocol_;\r
 \r
        std::array<char, 32768>                                         data_;\r
-\r
-       std::string                                                                     buffer_;\r
-\r
-       const spl::shared_ptr<IProtocolStrategy>        protocol_;\r
-       spl::shared_ptr<connection_set>                         connection_set_;\r
+       std::string                                                                     input_;\r
 \r
 public:\r
     static spl::shared_ptr<connection> create(spl::shared_ptr<tcp::socket> socket, const ProtocolStrategyPtr& protocol, spl::shared_ptr<connection_set> connection_set)\r
@@ -102,8 +100,8 @@ private:
     connection(const spl::shared_ptr<tcp::socket>& socket, const ProtocolStrategyPtr& protocol, const spl::shared_ptr<connection_set>& connection_set) \r
                : socket_(socket)\r
                , name_((socket_->is_open() ? u16(socket_->local_endpoint().address().to_string() + ":" + boost::lexical_cast<std::string>(socket_->local_endpoint().port())) : L"no-address"))\r
-               , protocol_(protocol)\r
                , connection_set_(connection_set)\r
+               , protocol_(protocol)\r
        {\r
                CASPAR_LOG(info) << print() << L" Connected.";\r
     }\r
@@ -116,12 +114,12 @@ private:
                        {\r
                                CASPAR_LOG(trace) << print() << L" Received: " << u16(std::string(data_.begin(), data_.begin() + bytes_transferred));\r
 \r
-                               buffer_.insert(buffer_.end(), data_.begin(), data_.begin() + bytes_transferred);\r
+                               input_.append(data_.begin(), data_.begin() + bytes_transferred);\r
                                \r
                                std::vector<std::string> split;\r
-                               boost::iter_split(split, buffer_, boost::algorithm::first_finder("\r\n"));\r
+                               boost::iter_split(split, input_, boost::algorithm::first_finder("\r\n"));\r
                                \r
-                               buffer_ = std::move(split.back());\r
+                               input_ = std::move(split.back());\r
                                split.pop_back();\r
 \r
                                BOOST_FOREACH(auto cmd, split)\r
@@ -139,8 +137,6 @@ private:
                }  \r
                else if (error != boost::asio::error::operation_aborted)\r
                        stop();         \r
-               else\r
-                       read_some();\r
     }\r
 \r
     void handle_write(const spl::shared_ptr<std::string>& data, const boost::system::error_code& error, size_t bytes_transferred)\r