当前位置: 首页>>代码示例>>C++>>正文


C++ Notification::addDataItem方法代码示例

本文整理汇总了C++中Notification::addDataItem方法的典型用法代码示例。如果您正苦于以下问题:C++ Notification::addDataItem方法的具体用法?C++ Notification::addDataItem怎么用?C++ Notification::addDataItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Notification的用法示例。


在下文中一共展示了Notification::addDataItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: toDo

Notification ActionUpdateClient::toDo() {

    pid_t child_pid;

    child_pid = fork();

    if (child_pid < 0) {
        cout << getpid() << " > Fork failed!!" << endl;
        abort();
    }

    if (child_pid == 0) {

        cout << getpid() << " > Me voy a actualizar!!" << endl;

        /*
         * Esperamos 5 segundos simulando un trabajo
         */

        sleep(10);

        cout << getpid() << " > Termino la actualizacion, creo una conneccion y envio el resultado" << endl;

        ConnectionSSL connection;
        connection.setClient(this->connection->getClient());
        connection.createEncryptedSocket();

        Notification persistent_sender;

        persistent_sender.setAction(ACTION_PERSISTENT_SENDER);
        persistent_sender.addDataItem(JSONNode("Token", ACCESS_TOKEN));

        OutcomingActionExecutor outcoming_executor(&connection);

        outcoming_executor.writeAndWaitResponse(persistent_sender);

        /*
         * Envio los resultados obtenidos
         */

        Notification response;
        response.setAction(ACTION_NOTIFICATION_RESPONSE);
        response.setParentId(this->notification.getId());
        response.clearData();
        response.addDataItem(JSONNode("UpdateStatus", "OK"));

        outcoming_executor.writeAndWaitResponse(response);


        /*
         * Cierro la coneccion
         */

        connection.informClosingToServer();

        connection.manageCloseConnection(0);

    }

    Notification response;
    response.setAction(ACTION_NOTIFICATION_RESPONSE);
    response.setParentId(this->notification.getId());
    response.clearData();
    response.addDataItem(JSONNode("UpdateStatus", "INICIADO"));

    return response;
    
}
开发者ID:iavalenzu,项目名称:RaspberryProject,代码行数:68,代码来源:ActionUpdateClient.cpp

示例2: main

int main(int argc, char** argv) {


    pid_t rc_pid;
    pid_t child_pid;
    int chld_state;



    struct sigaction sigact_close_client;

    sigemptyset(&sigact_close_client.sa_mask);
    sigact_close_client.sa_flags = 0;
    sigact_close_client.sa_handler = manageCloseClient;
    sigaction(SIGTERM, &sigact_close_client, NULL);
    sigaction(SIGABRT, &sigact_close_client, NULL);
    sigaction(SIGKILL, &sigact_close_client, NULL);
    sigaction(SIGINT, &sigact_close_client, NULL);

    child_pid = fork();

    if (child_pid < 0) {
        cout << getpid() << " > Fork failed!!" << endl;
        abort();
    }

    if (child_pid == 0) {

        cout << getpid() << " > Inciando proceso hijo PERSISTENT_RECEIVER!!" << endl;

        connection.setClient(&client);
        
        connection.createEncryptedSocket();

        OutcomingActionExecutor outcoming_executor(&connection);

        Notification notification;

        notification.setAction("PERSISTENT_RECEIVER");
        notification.addDataItem(JSONNode("Token", ACCESS_TOKEN));

        outcoming_executor.writeAndWaitResponse(notification);

        exit(0);

    } else {
        cout << getpid() << " > I'm your father " << child_pid << "!!" << endl;
    }


    /*
     * Esperamos a que los procesos hijos terminen
     */

    rc_pid = wait(&chld_state);

    cout << getpid() << " > Rc Pid: " << rc_pid << endl;

    return 0;

}
开发者ID:iavalenzu,项目名称:RaspberryProject,代码行数:61,代码来源:main.cpp


注:本文中的Notification::addDataItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。