/*
  broker.cpp

  Copyright (c) 2021 Kevin Matz (kevin.matz@gmail.com)

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  SOFTWARE.
*/
#include "broker.h"
#include "broker-protocol.h"

namespace RDMnet {

/**
 * @brief Broker::Broker
 * @param cid
 * @param uid
 */
Broker::Broker(UUID::uuid cid, RDM::UID uid)
  : Implementation(cid, uid)
  , EPT::Broker()
  , RPT::Broker()
{
  fctn_ = "OpenLCP RDMnet Broker";

  RlpRegisterVector(VECTOR_ROOT_BROKER, std::bind(&Broker::rlpBrokerReceiver,
                                                  this, std::placeholders::_1));
}


/**
 * @brief Broker::rlpBrokerReceiver
 * @param root
 */
void Broker::rlpBrokerReceiver(ACN::PDU::Message<ACN::RLP::Pdu> root)
{
  root->createDataBlock<BrokerProtocol::Pdu>();
  auto block = static_cast<ACN::PDU::Block<BrokerProtocol::Pdu>*>(root->data());
  for(auto const &frame : *block->pdu)
    {
      switch(frame->vector()) {
        case VECTOR_BROKER_CONNECT:
          break;
        case VECTOR_BROKER_CONNECT_REPLY:
          break;
        case VECTOR_BROKER_CLIENT_ENTRY_UPDATE:
          break;
        case VECTOR_BROKER_REDIRECT_V4:
          break;
        case VECTOR_BROKER_REDIRECT_V6:
          break;
        case VECTOR_BROKER_FETCH_CLIENT_LIST:
          break;
        case VECTOR_BROKER_CONNECTED_CLIENT_LIST:
          break;
        case VECTOR_BROKER_CLIENT_ADD:
          break;
        case VECTOR_BROKER_CLIENT_REMOVE:
          break;
        case VECTOR_BROKER_CLIENT_ENTRY_CHANGE:
          break;
        case VECTOR_BROKER_REQUEST_DYNAMIC_UIDS:
          break;
        case VECTOR_BROKER_ASSIGNED_DYNAMIC_UIDS:
          break;
        case VECTOR_BROKER_FETCH_DYNAMIC_UID_LIST:
          break;
        case VECTOR_BROKER_DISCONNECT:
          break;
        case VECTOR_BROKER_NULL:
          break;
        default:
          break;
        }
    }
}

} // namespace RDMnet
