Commit 6336b4fb authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

sample code of using CC API


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/f2f200910@256 e5f2f494-b856-4b98-b285-d166d9295462
parent 392839e6
// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
// $Id$
#include <stdexcept>
#include <string.h>
#include <cc/cpp/data.h>
#include <cc/cpp/session.h>
using std::string;
class SessionManager {
public:
SessionManager();
private:
ISC::CC::Session session_;
};
SessionManager::SessionManager() :
session_(ISC::CC::Session())
{
try {
session_.establish();
session_.subscribe("ParkingLot");
session_.subscribe("Boss");
} catch (...) {
throw std::runtime_error("SessionManager: failed to open sessions");
}
}
std::pair<string, string>
getCommand(ISC::CC::Session& session)
{
ISC::Data::ElementPtr ep, routing, data;
session.group_recvmsg(routing, data, false);
ep = data->get("zone_added");
if (ep != NULL) {
return std::pair<string, string>("zone_added", ep->string_value());
}
ep = data->get("zone_deleted");
if (ep != NULL) {
return std::pair<string, string>("zone_deleted", ep->string_value());
}
ep = data->get("shutdown");
if (ep != NULL) {
return std::pair<string, string>("shutdown", "");
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment