void channel_impl::close_(uint16_t reply_code, const std::string& reply_text, uint16_t class_id, uint16_t method_id)
{
  methods::channel::close::ptr_t close = methods::channel::close::create();
  close->set_reply_code(reply_code);
  close->set_reply_text(reply_text);
  close->set_class_id(class_id);
  close->set_method_id(method_id);

  m_continuation = boost::bind(&channel_impl::closed_handler, this, _1);

  m_connection->begin_write_method(get_channel_id(), close);
}
boost::unique_future<typename ResponseMethodT::ptr_t> channel_impl::begin_rpc(const typename SentMethodT::ptr_t& method)
{
  typedef boost::promise<typename ResponseMethodT::ptr_t> rpc_promise_t;
  typedef boost::shared_ptr<rpc_promise_t> rpc_promise_ptr_t;

  if (!m_channel_closed_future.is_ready())
  {
    frame::ptr_t out_frame = frame::create_from_method(get_channel_id(), method);

    rpc_promise_ptr_t rpc_promise = boost::make_shared<rpc_promise_t>();

    m_continuation = boost::bind(&channel_impl::rpc_handler<ResponseMethodT>, this, _1, rpc_promise);

    m_connection->begin_write_method(get_channel_id(), method);

    return rpc_promise->get_future();
  }
  else
  {
    throw std::runtime_error("Channel closed");
  }
}
Beispiel #3
0
void supla_device_channels::set_channels_value(TDS_SuplaDeviceChannel_B *schannel, int count) {

	for(int a=0;a<count;a++)
		set_channel_value(get_channel_id(schannel[a].Number), schannel[a].value);

}