zoukankan      html  css  js  c++  java
  • 11

    #include <stdio.h>
    #include <stdlib.h>

    #include <avis/elvin.h>
    #include <avis/errors.h>
    #include <avis/stdtypes.h>
    #include "errors_private.h"
    #include "avis/attributes.h"
    #include "avis/keys.h"

    void test_subscribe_sub_listener (Subscription *sub,
    Attributes *attributes, bool secure,
    void *user_data)
    {
    Array *data = attributes_get_opaque (attributes, "opaque");
    }

    int main(int argc, char* argv[]) {
    Elvin elvin;
    Subscription *sub;
    Attributes *ntfn = attributes_create ();
    Array data;

    data.item_count = 100 * 1024;
    data.items = malloc (data.item_count);

    memset (data.items, 42, data.item_count);

    /* check invalid subscription is handled */
    sub = elvin_subscribe (&elvin, "size (bogus");

    sub =
    elvin_subscribe
    (&elvin,
    "require (test) && string (message) && int32 == 32 && int64 == 64L");

    elvin_subscription_add_listener (sub, test_subscribe_sub_listener,
    "user_data");

    attributes_set_int32 (ntfn, "test", 1);
    attributes_set_int32 (ntfn, "int32", 32);
    attributes_set_int64 (ntfn, "int64", 64);
    attributes_set_real64 (ntfn, "pi", 3.14);
    attributes_set_string (ntfn, "message", "hello world");
    attributes_set_opaque (ntfn, "opaque", data);

    elvin_send (&elvin, ntfn) && elvin_poll (&elvin);

    //elvin_unsubscribe (&elvin, sub);

    /* test sub change*/
    sub = elvin_subscribe (&elvin, "require (bogus)");

    /*elvin_subscription_add_listener (sub, test_subscribe_sub_listener,
    "user_data");*/

    //elvin_subscription_set_expr (sub, "require (test)");

    elvin_send (&elvin, ntfn) && elvin_poll (&elvin);

    attributes_destroy (ntfn);

    /* test general listener */
    ntfn = attributes_create ();
    attributes_set_int32 (ntfn, "test", 1);

    attributes_destroy (ntfn);

    elvin_unsubscribe (&elvin, sub);

    elvin_close (&elvin);

    system("pause");
    }

  • 相关阅读:
    我拒绝接受的几个最佳编程实践方法
    女人千万别写代码
    Visual Studio原生开发的10个调试技巧(二)
    20个很有用的PHP类库
    8个开发必备的PHP功能
    青少年如何使用 Python 开始游戏开发
    rmdir 删除空目录
    rm 删除文件或目录
    mv 移动或重命名文件
    cp 复制文件或目录
  • 原文地址:https://www.cnblogs.com/xiaomaogong/p/3645147.html
Copyright © 2011-2022 走看看