Пример #1
0
 virtual bool process( ::boost::shared_ptr< osiris::HttpSession > session, ::osiris::HttpPath const & path ) {
     ::osiris::PythonState __pystate(getPythonThreadState());
     if( ::osiris::PythonOverride func_process = this->get_override( "process" ) )
         return func_process( session, boost::ref(path) );
     else{
         __pystate.leave();
         return this->::osiris::IHttpDirectory::process( session, boost::ref(path) );
     }
 }
Пример #2
0
/**
 * poll info peer has information 
 * */
int network_poll(void* caller, void **udata,
               const int msec_timeout,
               int (*func_process) (void *caller,
                                    void* nethandle,
                                    const char* buf,
                                    unsigned int len),
               void (*func_process_connection) (void *,
                                                void* nethandle,
                                                char *ip,
                                                int port)
               )
{
    client_t* me = *udata;
    hashmap_iterator_t iter;

    /* loop throught each connection for this peer */
    for (
        hashmap_iterator(me->connections, &iter);
        hashmap_iterator_has_next(me->connections, &iter);
        )
    {
        client_connection_t* cn;

        cn = hashmap_iterator_next_value(me->connections, &iter);

        /* we need to process a connection request created by the peer */
        if (0 == cn->connect_status)
        {
            char ip[32];

            sprintf(ip, "%p", cn->nethandle);

#if 0 /* debugging */
            printf("processing connection me:%d them:%d\n",
                    me->nethandle, cn->nethandle);
#endif

            func_process_connection(me->bt, cn->nethandle, ip, 4000);
            cn->connect_status = CS_CONNECTED;
        }
        else if (!bipbuf_is_empty(cn->inbox))
        {
            int len = bipbuf_get_spaceused(cn->inbox);
            if (0 < len)
                func_process(me->bt,
                             (char*)cn->nethandle,
                             (char*)bipbuf_poll(cn->inbox, len), len);
        }
    }

    return 1;
}