HttpRequest::HttpRequest(const string& sub, const RequestType& type):
    m_contents()
{
    setHttpVersion("1.1");
    setRequestType(type);
    setSub(sub);
}
Beispiel #2
0
void DataModel::createDatabase()
{
	auto request = new HttpRequest();
	std::string url = "";

	if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32){
		// Lay du lieu tu localhost
		url = "http://127.0.0.1/cocos2dx/database.db3";
	}
	if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID){
		/*Them port cho firewall va chuyen ServerName thanh dia chi ip cua may
		* Lay data tu localhost nay(device va server phai dat cung 1 mang LAN)
		*/
		url = "http://192.168.0.208:80/cocos2dx/database.db3";
	}
	log("URL: %s ", url.c_str());
	request->setUrl(url.c_str());
	// Thuc hien gui request len server theo phuong thuc GET
	request->setRequestType(HttpRequest::Type::GET);
	// Thiet lap callback khi request duoc gui toi server va server tra lai du lieu 
	/*Cocos2dx V2.2*/
	//request->setResponseCallback(this, httpresponse_selector(ModeSelectScene::serverCallback));
	/*Cocos2dx V3.4*/
	request->setResponseCallback(CC_CALLBACK_2(DataModel::serverCallback, this));
	// Gui request len server
	auto client = HttpClient::getInstance();
	client->enableCookies(NULL);
	client->send(request);
	request->release();
}
Beispiel #3
0
ConfigHandler::ConfigHandler(User *user, const std::string &from, const std::string &id) : m_from(from), m_user(user) {
    setRequestType(CALLER_ADHOC);
    std::string bare(JID(from).bare());

    IQ _response(IQ::Result, from, id);
    Tag *response = _response.tag();
    response->addAttribute("from", Transport::instance()->jid());

    AdhocTag *adhocTag = new AdhocTag(Transport::instance()->getId(), "transport_irc_config", "executing");
    adhocTag->setAction("complete");
    adhocTag->setTitle("IRC Nickserv password configuration");
    adhocTag->setInstructions("Choose the server you want to change password for.");

    std::map <std::string, std::string> values;
    std::map<std::string, UserRow> users = Transport::instance()->sql()->getUsersByJid(bare);
    for (std::map<std::string, UserRow>::iterator it = users.begin(); it != users.end(); it++) {
        std::string server = (*it).second.jid.substr(bare.size());
        values[server] = stringOf((*it).second.id);
        m_userId.push_back(stringOf((*it).second.id));
    }
    adhocTag->addListSingle("IRC server", "irc_server", values);

    adhocTag->addTextPrivate("New NickServ password", "password");

    response->addChild(adhocTag);
    Transport::instance()->send(response);
}
Beispiel #4
0
void GBUpdate::requestRemoteVersion()
{
	GBVersion version = splitVersion(getLocalVersion());

	auto request = new (std::nothrow) HttpRequest();
	request->setUrl(StringUtils::format("%s/%d.%d/md5", _updateUrl.c_str(), version.version1, version.version2).c_str());
	request->setRequestType(HttpRequest::Type::GET);
	request->setResponseCallback(CC_CALLBACK_2(GBUpdate::onRequestVersionCompleted, this));
	HttpClient::getInstance()->sendImmediate(request);
	request->release();
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Point origin = Director::getInstance()->getVisibleOrigin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    auto closeItem = MenuItemImage::create(
                                           "CloseNormal.png",
                                           "CloseSelected.png",
                                           CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
    
	closeItem->setPosition(Point(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
                                origin.y + closeItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    auto menu = Menu::create(closeItem, NULL);
    menu->setPosition(Point::ZERO);
    this->addChild(menu, 1);

    /////////////////////////////
    // 3. add your codes below...

    // add a label shows "Hello World"
    // create and initialize a label
    
    auto label = LabelTTF::create("Hello World", "Arial", 24);
    
    // position the label on the center of the screen
    label->setPosition(Point(origin.x + visibleSize.width/2,
                            origin.y + visibleSize.height - label->getContentSize().height));

    // add the label as a child to this layer
    this->addChild(label, 1);


    auto request = new extension::HttpRequest();
    request->setUrl("http://befool.co.jp/images/logo_befool.jpg");
    request->setRequestType(extension::HttpRequest::Type::GET);
    request->setResponseCallback(this, httpresponse_selector(HelloWorld::onHttpRequestCompleted));
    extension::HttpClient::getInstance()->send(request);

    return true;
}
void OfflineMessagesTask::deleteOfflineMessages()
{
	FLAP f = { 0x02, 0, 0 };
	SNAC s = { 0x0015, 0x0002, 0x0000, client()->snacSequence() };
	
	
	setRequestType( 0x003E ); //delete offline messages
	setSequence( m_sequence );
	Buffer* buf = addInitialData();
	Transfer* t = createTransfer( f, s, buf );
	send( t );
}
void OfflineMessagesTask::onGo()
{
	kdDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Requesting offline messages" << endl;
	
	FLAP f = { 0x02, 0, 0 };
	SNAC s = { 0x0015, 0x0002, 0x0000, client()->snacSequence() };
	
	setRequestType( 0x003c ); //offline message request
	setSequence( f.sequence );
	Buffer* buf = addInitialData();
	Transfer* t = createTransfer( f, s, buf );
	send( t );
}
Beispiel #8
0
void MenuScene::makeHttpRequest(){
    auto request = new cocos2d::network::HttpRequest();
    request->setUrl("https://www.google.com");
    request->setRequestType(cocos2d::network::HttpRequest::Type::GET);
    
    request->setResponseCallback( [&] (network::HttpClient* client, network::HttpResponse* response) {
        if (!response)
        {
            return;
        }
        // Dump the data
        std::vector<char>* buffer = response->getResponseData();
        for (unsigned int i = 0; i <buffer-> size (); i ++)
        {
            log ("% c", (* buffer) [i]);
        }
    });
    
    cocos2d::network::HttpClient::getInstance()->send(request);
    request->release();
}
void ICQTlvInfoRequestTask::onGo()
{
	kDebug(OSCAR_RAW_DEBUG) << "Requsting full TLV user info for: " << m_userToRequestFor;

	setSequence( client()->snacSequence() );
	setRequestType( 0x07D0 );
	setRequestSubType( 0x0FA0 );

	Buffer b;

	b.startBlock( Buffer::BWord, Buffer::LittleEndian );
	// Magic numbers
	b.addDWord( 0x05b90002 );
	b.addDWord( 0x80000000 );
	b.addDWord( 0x00000006 );
	b.addDWord( 0x00010002 );
	b.addDWord( 0x00020000 );
	b.addDWord( 0x04e20000 );
	b.addWord( 0x0002 );
	b.addWord( m_type );
	b.addDWord( 0x00000001 );

	b.startBlock( Buffer::BWord );
	b.addTLV( 0x003C, m_metaInfoId );
	b.addTLV( 0x0032, m_userToRequestFor.toLatin1() );
	b.endBlock();

	b.endBlock();

	Buffer *sendBuf = addInitialData( &b );

	Oscar::DWORD seq = client()->snacSequence();
	m_contactSequenceMap[seq] = m_userToRequestFor;

	FLAP f = { 0x02, 0, 0 };
	SNAC s = { 0x0015, 0x0002, 0, seq };
	Transfer* t = createTransfer( f, s, sendBuf );
	send( t );
}