예제 #1
0
 /// Constructor
 connection(
     server& parent,
     tcp::endpoint const& ep,
     tcp::socket&& sock)
     : log_(parent.log_)
     , ep_(ep)
     , ws_(std::move(sock))
     , timer_(ws_.get_io_service(), (clock_type::time_point::max)())
     , strand_(ws_.get_io_service())
     , id_([]
         {
             static std::atomic<std::size_t> n{0};
             return ++n;
         }())
 {
     // Invoke the callback for new connections if set.
     // This allows the settings on the websocket stream
     // to be adjusted. For example to turn compression
     // on or off or adjust the read and write buffer sizes.
     //
     if(parent.mod_)
         parent.mod_(ws_);
 }