コード例 #1
0
ファイル: ccnetrpc-transport.c プロジェクト: andrey-str/ccnet
int
ccnetrpc_async_transport_send (void *arg, gchar *fcall_str,
                             size_t fcall_len, void *rpc_priv)
{
    CcnetrpcAsyncTransportParam *priv;
    CcnetClient *session;
    CcnetProcessor *proc;

    g_warn_if_fail (arg != NULL && fcall_str != NULL);

    priv = (CcnetrpcAsyncTransportParam *)arg;
    session = priv->session;
    
    if (!priv->peer_id)
        proc = ccnet_proc_factory_create_master_processor (
            session->proc_factory, "async-rpc");
    else
        proc = ccnet_proc_factory_create_remote_master_processor (
            session->proc_factory, "async-rpc", priv->peer_id);
    
    ccnet_async_rpc_proc_set_rpc ((CcnetAsyncRpcProc *)proc, priv->service, 
                                  fcall_str, fcall_len, rpc_priv);
    ccnet_processor_start (proc, 0, NULL);
    return 0;
}
コード例 #2
0
ファイル: mq-mgr.c プロジェクト: Armadillux/seafile
SeafMqManager *
seaf_mq_manager_new (SeafileSession *seaf)
{
    CcnetClient *client = seaf->session;
    SeafMqManager *mgr;
    SeafMqManagerPriv *priv;

    mgr = g_new0 (SeafMqManager, 1);
    priv = g_new0 (SeafMqManagerPriv, 1);
    
    
    mgr->seaf = seaf;
    mgr->priv = priv;

    priv->mqclient_proc = (CcnetMqclientProc *)
        ccnet_proc_factory_create_master_processor (client->proc_factory,
                                                    "mq-client");

    if (!priv->mqclient_proc) {
        seaf_warning ("Failed to create mqclient proc.\n");
        g_free (mgr);
        g_free(priv);
        return NULL;
    }

    return mgr;
}
コード例 #3
0
ファイル: seafile-controller.c プロジェクト: krutten/seafile
static int
start_mq_client ()
{
    seaf_message ("starting mq client ...\n");
    
    CcnetMqclientProc *mqclient_proc;

    mqclient_proc = (CcnetMqclientProc *)
        ccnet_proc_factory_create_master_processor
        (ctl->client->proc_factory, "mq-client");
    
    if (!mqclient_proc) {
        seaf_warning ("Failed to create mqclient proc.\n");
        return -1;
    }

    static char *topics[] = {
        "seaf_server.heartbeat",
        "seaf_mon.heartbeat",
    };

    ccnet_mqclient_proc_set_message_got_cb (mqclient_proc, mq_cb, NULL);

    /* Subscribe to messages. */
    if (ccnet_processor_start ((CcnetProcessor *)mqclient_proc,
                               G_N_ELEMENTS(topics), topics) < 0) {
        seaf_warning ("Failed to start mqclient proc\n");
        return -1;
    }

    ctl->mqclient_proc = mqclient_proc;

    return 0;
}
コード例 #4
0
ファイル: applet-common.c プロジェクト: asukaliy/seafile
static void
start_mq_client ()
{
    CcnetMqclientProc *mqclient_proc;
    
    mqclient_proc = (CcnetMqclientProc *)
        ccnet_proc_factory_create_master_processor
        (applet->client->proc_factory, "mq-client");

    if (!mqclient_proc) {
        applet_warning ("Failed to create mq-client!\n");
        applet_exit(1);
    }

    ccnet_mqclient_proc_set_message_got_cb (mqclient_proc, mq_cb, NULL);
    
    static char *topics[] = {
        "seafile.heartbeat",
        "seafile.notification",
    };
    
    /* Subscribe to messages. */
    if (ccnet_processor_start ((CcnetProcessor *)mqclient_proc,
                               G_N_ELEMENTS(topics), topics) < 0) {
        
        applet_warning ("Failed to start mq-client!\n");
        applet_exit(1);
    }

    applet->mqclient_proc = mqclient_proc;
}
コード例 #5
0
ファイル: service-proxy-proc.c プロジェクト: 9thsector/ccnet
void
ccnet_service_proxy_invoke_remote (CcnetProcessor *processor,
                                   CcnetPeer *remote,
                                   int argc, char **argv)
{
    CcnetServiceStubProc *stub_proc;
    ServiceProxyPriv *priv = GET_PRIV(processor);

    if (argc < 1) {
        ccnet_processor_send_response (processor, SC_BAD_CMD_FMT,
                                       SS_BAD_CMD_FMT, NULL, 0);
        ccnet_processor_done (processor, FALSE);
        return;
    }
    
    priv->name = proc_name_strjoin_n(" ", argc, argv);

    stub_proc = CCNET_SERVICE_STUB_PROC (
        ccnet_proc_factory_create_master_processor (
            processor->session->proc_factory, "service-stub", remote)
        );
    priv->stub_proc = stub_proc;
    ccnet_service_stub_proc_set_proxy_proc (stub_proc, processor);

    /* Start can fail if the remote end is not connected. */
    if (ccnet_processor_start (CCNET_PROCESSOR(stub_proc), argc, argv) < 0) {
        ccnet_processor_send_response (processor, SC_PROC_DEAD, SS_PROC_DEAD,
                                       NULL, 0);
        ccnet_processor_done (processor, FALSE);
    }
}
コード例 #6
0
ファイル: service-proxy-proc.c プロジェクト: 9thsector/ccnet
/* TODO: the same as above, can use one function instead */
void
ccnet_service_proxy_invoke_local (CcnetProcessor *processor,
                                  CcnetPeer *local,
                                  int argc, char **argv)
{
    CcnetServiceStubProc *stub_proc;
    ServiceProxyPriv *priv = GET_PRIV(processor);
    
    if (argc < 1) {
        ccnet_processor_send_response (processor, SC_BAD_CMD_FMT,
                                       SS_BAD_CMD_FMT, NULL, 0);
        ccnet_processor_done (processor, FALSE);
        return;
    }

    priv->name = proc_name_strjoin_n(" ", argc, argv);

    stub_proc = CCNET_SERVICE_STUB_PROC (
        ccnet_proc_factory_create_master_processor (
            processor->session->proc_factory, "service-stub", local)
        );
    priv->stub_proc = stub_proc;
    ccnet_service_stub_proc_set_proxy_proc (stub_proc, processor);

    ccnet_processor_start (CCNET_PROCESSOR(stub_proc), argc, argv);
}
コード例 #7
0
ファイル: mainloop.c プロジェクト: andrey-str/ccnet
void ccnet_send_command (CcnetClient *client, const char *command,
                         SendcmdProcRcvrspCallback cmd_cb, void *cbdata)
{
    CcnetSendcmdProc *sendcmd_proc = (CcnetSendcmdProc *)
        ccnet_proc_factory_create_master_processor (client->proc_factory,
                                                    "send-cmd");
    ccnet_sendcmd_proc_set_rcvrsp_cb (sendcmd_proc, cmd_cb, cbdata);
    ccnet_processor_start (CCNET_PROCESSOR(sendcmd_proc), 0, NULL);
    ccnet_sendcmd_proc_send_command (sendcmd_proc, command);    
}
コード例 #8
0
ファイル: connect-mgr.c プロジェクト: F0rth/seafile-obsd-wip
void start_keepalive (CcnetPeer *peer)
{
    CcnetProcessor *processor;
    CcnetProcFactory *factory = peer->manager->session->proc_factory;
    
    processor = ccnet_proc_factory_create_master_processor (factory,
                                                    "keepalive2", peer);
    if (processor == NULL) {
        ccnet_warning ("Create keepalive2 processor failed\n");
        return;
    }
    ccnet_processor_startl (processor, NULL);
}
コード例 #9
0
ファイル: keepalive-proc.c プロジェクト: 9thsector/ccnet
static void get_user_pubinfo (CcnetPeer *peer)
{
    CcnetProcessor *newp;
    CcnetProcFactory *factory = peer->manager->session->proc_factory;
    
    newp = ccnet_proc_factory_create_master_processor (factory,
                                          "get-user", peer);
    if (newp == NULL) {
        ccnet_warning ("Create get user info processor failed\n");
        return;
    }
    ccnet_processor_startl (newp, NULL);
}
コード例 #10
0
ファイル: connect-mgr.c プロジェクト: F0rth/seafile-obsd-wip
static void on_unauthed_peer_connected (CcnetPeer *peer, CcnetPacketIO *io)
{
    CcnetProcessor *processor;
    CcnetProcFactory *factory = peer->manager->session->proc_factory;

    ccnet_peer_set_io (peer, io);              
    ccnet_peer_set_net_state (peer, PEER_CONNECTED);

    processor = ccnet_proc_factory_create_master_processor (
        factory, "get-pubinfo", peer);
    if (processor == NULL) {
        ccnet_warning ("Create get-pubinfo processor failed\n");
        ccnet_peer_shutdown (peer);
        return;
    }
    g_signal_connect (processor, "done",
                      G_CALLBACK(on_get_unauth_peer_pub_info_done), NULL);

    ccnet_processor_startl (processor, NULL);
}
コード例 #11
0
void MessageListener::startMqClient()
{
    mqclient_proc_ = (CcnetMqclientProc *)
        ccnet_proc_factory_create_master_processor
        (async_client_->proc_factory, "mq-client");

    ccnet_mqclient_proc_set_message_got_cb (mqclient_proc_,
                                            (MessageGotCB)messageCallback,
                                            this);

    static const char *topics[] = {
        // "seafile.heartbeat",
        "seafile.notification",
    };

    if (ccnet_processor_start ((CcnetProcessor *)mqclient_proc_,
                               G_N_ELEMENTS(topics), (char **)topics) < 0) {

        seafApplet->errorAndExit("Failed to start mq client");
    }
}