コード例 #1
0
ファイル: OlaServerServiceImpl.cpp プロジェクト: basileus/ola
/*
 * Register a client to receive DMX data.
 */
void OlaServerServiceImpl::RegisterForDmx(
    RpcController* controller,
    const RegisterDmxRequest* request,
    Ack*,
    ola::rpc::RpcService::CompletionCallback* done,
    Client *client) {
  ClosureRunner runner(done);
  Universe *universe = m_universe_store->GetUniverseOrCreate(
      request->universe());
  if (!universe)
    return MissingUniverseError(controller);

  if (request->action() == ola::proto::REGISTER) {
    universe->AddSinkClient(client);
  } else {
    universe->RemoveSinkClient(client);
  }
}
コード例 #2
0
/*
 * Check that we can add/remove sink clients from this universes
 */
void UniverseTest::testSinkClients() {
  Universe *universe = m_store->GetUniverseOrCreate(TEST_UNIVERSE);
  OLA_ASSERT(universe);
  OLA_ASSERT_EQ((unsigned int) 0, universe->SourceClientCount());
  OLA_ASSERT_EQ((unsigned int) 0, universe->SinkClientCount());

  // test that we can add a source client
  MockClient client;
  universe->AddSinkClient(&client);
  OLA_ASSERT_EQ((unsigned int) 1, universe->SinkClientCount());
  OLA_ASSERT_EQ((unsigned int) 0, universe->SourceClientCount());
  OLA_ASSERT(universe->ContainsSinkClient(&client));
  OLA_ASSERT_FALSE(universe->ContainsSourceClient(&client));
  OLA_ASSERT(universe->IsActive());

  // Setting DMX now should update the client
  OLA_ASSERT_FALSE(client.m_dmx_set);
  universe->SetDMX(m_buffer);
  OLA_ASSERT(client.m_dmx_set);

  // now remove it
  universe->RemoveSinkClient(&client);
  OLA_ASSERT_EQ((unsigned int) 0, universe->SinkClientCount());
  OLA_ASSERT_EQ((unsigned int) 0, universe->SourceClientCount());
  OLA_ASSERT_FALSE(universe->ContainsSinkClient(&client));
  OLA_ASSERT_FALSE(universe->ContainsSourceClient(&client));
  OLA_ASSERT_FALSE(universe->IsActive());

  // try to remove it again
  OLA_ASSERT_FALSE(universe->RemoveSinkClient(&client));
  OLA_ASSERT_EQ((unsigned int) 0, universe->SinkClientCount());
  OLA_ASSERT_EQ((unsigned int) 0, universe->SourceClientCount());
  OLA_ASSERT_FALSE(universe->ContainsSinkClient(&client));
  OLA_ASSERT_FALSE(universe->ContainsSourceClient(&client));
  OLA_ASSERT_FALSE(universe->IsActive());
}