示例#1
0
      void sessionList::new_session(t_long & _new_session)
      {
         bool unique = false;

         while (!unique)
            {
               get_session(_new_session);
               if (check_session(_new_session))
                  {
                     unique = true;
                  }
            }
      }
示例#2
0
      void sessionList::new_session(t_long & _new_session)
      {
         boost::mutex::scoped_lock interface_lock(interfaceMutex_);

         bool unique = false;

         while (!unique)
            {
               get_session(_new_session);
               if (check_session(_new_session))
                  {
                     unique = true;
                  }
            }
      }
示例#3
0
int
main (int argc, char **argv) {
    char assertion[4080]; /* = "lskdajfljk23l4j23lkj423lkj423klj4l23kj423klj4jkl423lj";*/
    char email[1024];
    strcpy(assertion, argv[1]);
    /* given an assertion, do we know the email address? */
    /* yes - return email 
       no - no session yet
       error - something went horribly wrong ;) - Handle errors directly, quit plugin
    */
    if (check_session(assertion, &email) == 1) {
        printf("Got email=%s\n", email);
        /* set user into the session or whatever... */
    } else {
        /* New Session! */
        /* do auth or whatever */
        create_session(assertion, "*****@*****.**");
    }
    
}
示例#4
0
	void response_base< Timer >::handle_request( const json::object& request,
	    const boost::shared_ptr< response_interface >& self, const std::string& connection_name, bool last_message )
	{
		const json::string channel = extract_channel( request );

		if ( channel == meta_handshake_channel )
		{
			handle_handshake( request, connection_name );
			return;
		}

		const json::string client_id = check_client_id( request, channel );
		if ( client_id.empty() )
		    return;

		if ( !check_session( request, client_id, channel ) )
		    return;

        if ( channel == meta_connect_channel )
        {
            handle_connect( request, self, last_message );
        }
        else if ( channel == meta_disconnect_channel )
        {
            handle_disconnect( request );
        }
        else if ( channel == meta_subscribe_channel )
        {
            handle_subscribe( request );
        }
        else if ( channel == meta_unsubscribe_channel )
        {
            handle_unsubscribe( request );
        }
        else
        {
            handle_publish( channel, request );
        }
	}
示例#5
0
int callback_home(struct lws *wsi, enum lws_callback_reasons reason, void *user,
    void *in, size_t len)  {

    struct per_session_data__details *pss =
    (struct per_session_data__details *)user; 




    switch (reason) {
        case LWS_CALLBACK_PROTOCOL_INIT:{
            break;
        }
        case LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION:
        {            
            check_session(wsi,pss);
            increment_client_count();
            if(lst_find(&clinets_lst,pss->uid)<0){
                lst_append(&clinets_lst, pss->user,pss->uid,pss->gid,pss->session_id+24);
            }               
            break; 
        }         
        case LWS_CALLBACK_WS_PEER_INITIATED_CLOSE:
        {
            new_user=pss->user;
            decrement_client_count();
            lst_remove(&clinets_lst,pss->uid);
        }   
        case LWS_CALLBACK_ESTABLISHED:
        {

            dump_user_info(pss);
            new_user=pss->user;


        }
        case LWS_CALLBACK_SERVER_WRITEABLE:
        {         
            if(strncmp(pss->checked,hash,32)!=0){
                memcpy(pss->checked,hash,32);
                
                char *out = lst_json(&clinets_lst);

                int count = strlen(out);

                unsigned char buffer[LWS_PRE + count];
                unsigned char *p = &buffer[LWS_PRE];

                int n = sprintf((char *)p, "%s", out);

                lws_write(wsi, p,  n, LWS_WRITE_TEXT);  
                free(out);  
                    
                break;              

            }


            
            break;
        }
        case LWS_CALLBACK_RECEIVE:
        {
        //received_msg = (char *) in;
        //chalter=1;
        //lws_callback_on_writable_all_protocol(lws_get_context(wsi),lws_get_protocol(wsi));

            break;
        }  
        default:
        break;      

    }
    return 0;
}
示例#6
0
//=========================================================================
scx::Condition Host::connect_request(MessageStream* message,
                                     Request& request,
                                     Response& response)
{
  HandlerMap* h = 0;

  const scx::Uri& uri = request.get_uri();
  const std::string& uripath = scx::Uri::decode(uri.get_path());

  // Check valid path
  if (!check_path(uripath)) {
    response.set_status(http::Status::Forbidden);
    return scx::Close;
  }
  
  // Check http authorization
  if (!check_auth(request,response)) {
    response.set_status(http::Status::Unauthorized);
    return scx::Close;
  }
  
  scx::FilePath path = m_docroot + uripath;
  request.set_path(path);
  
  std::string pathinfo;
  h = lookup_path_map(uripath,pathinfo);
  if (h) {
    // Path mapped module
    request.set_path_info(pathinfo);
  } else {
    // Normal file mapping
    scx::FileStat stat(path);
    if (!stat.exists()) {
      response.set_status(http::Status::NotFound);
      return scx::Close;
    } else if (stat.is_dir()) {
      h = lookup_extn_map(".");
    } else {
      h = lookup_extn_map(uripath);
    }
  }

  check_session(request,response);

  scx::Log log("http.hosts");
  log.attach("id", m_id);
  log.attach("message", request.get_id());
  log.attach("handler", h ? h->get_type() : "NONE");
  log.attach("session", request.get_session() ?
             request.get_session()->get_id() : "NONE");
  log.submit("Handling message");
  
  // Check we have a handler
  if (h == 0) {
    LOG("No handler found for request");
    response.set_status(http::Status::ServiceUnavailable);
    return scx::Close;
  }

  // Invoke the handler
  return h->handle_message(message);
}