Example #1
0
static void
release_resource(CcnetProcessor *processor)
{
    CcnetSendmsgProcPriv *priv = GET_PRIV (processor);

    ccnet_message_unref (priv->message);

    CCNET_PROCESSOR_CLASS (ccnet_sendmsg_proc_parent_class)->release_resource (processor);
}
Example #2
0
static void handle_update (CcnetProcessor *processor,
                           char *code, char *code_msg,
                           char *content, int clen)
{
    CcnetMessage *msg;

    if (processor->peer->is_local) {
        msg = ccnet_message_from_string_local (content, clen);
        ccnet_send_message (processor->session, msg);
        ccnet_message_unref (msg);
    } else {
        msg = ccnet_message_from_string (content, clen);
        if (!msg) {
            g_warning ("Wrong message format.\n");
            ccnet_processor_done (processor, FALSE);
            return;
        }

        msg->rtime = time(NULL);
        ccnet_debug ("[msg] Received a message : %s - %.10s\n", 
                     msg->app, msg->body);

        int ret = ccnet_recv_message (processor->session, msg);
        if (ret == -1) {
            ccnet_message ("[msg] Message from %.8s permission error\n", 
                           msg->from);
            ccnet_processor_send_response (processor, SC_PERM_ERR,
                                           SS_PERM_ERR, NULL, 0);
            ccnet_processor_done (processor, TRUE);
            ccnet_message_unref (msg);
            return;
        }

        ccnet_message_unref (msg);
    }

    ccnet_processor_send_response (processor, "200", "OK", NULL, 0);
    ccnet_processor_done (processor, TRUE);
}