示例#1
0
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
int
seaf_sync_manager_notify_peer_sync (SeafSyncManager *mgr,
                                    const char *repo_id,
                                    const char *peer_id,
                                    GError **error)
{
    CcnetProcessor *processor;
    char *token;

    if (!repo_id || !peer_id) {
        return -1;
    }

    token = seaf_repo_manager_generate_tmp_token (seaf->repo_mgr,
                                                  repo_id, peer_id);
    if (!token) {
        seaf_warning ("[sync-mgr] failed to generate tmp token for repo %s.\n",
                      repo_id);
        return -1;
    }
    processor = ccnet_proc_factory_create_remote_master_processor (
        seaf->session->proc_factory, "seafile-notifysync", peer_id);
    if (!processor) {
        seaf_warning ("[sync-mgr] failed to create get seafile-notifysync proc.\n");
        return -1;
    }

    if (ccnet_processor_startl (processor, repo_id, token, NULL) < 0) {
        seaf_warning ("[sync-mgr] failed to start get seafile-notifysync proc.\n");
        g_free (token);
        return -1;
    }

    seaf_debug ("[sync-mgr] Notify peer %s sync repo %s in lan\n",
                peer_id, repo_id);
    g_free (token);
    return 0;
}