Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Ichiro
    @HadesD
    oh, tks
    daz
    @bigg-daz
    How does the trantor callback API work?
    using RecvMessageCallback = std::function< void(const TcpConnectionPtr &, MsgBuffer *)>
    Do I read the MsgBuffer to read stuff sent by the client and write into the MsgBuffer to send stuff to the client or do I need to use TcpConnectionPtr->getRecvBuffer() to read and/or write?
    daz
    @bigg-daz
    Nvm found out how it works through the drogon code.
    headofdeveloper
    @headofdeveloper
    hello @an-tao when we get a new http request, the parseJson() is running by default or not? I dont want to get a JSON object - so in terms of performance perspective I dont need to have json object. getBody is enough for me
    An Tao
    @an-tao
    drogon don't parse the json body until you call the getJsonObject method first time.
    Roman Baschmakov
    @r.baschmakov_gitlab
    Hello dear community! I have a question about db client transactions. What exactly are they for? On my attempt to fire a SQLite3 script which is a multi statement transaction drogon tells me it doesn't support transactions.
    Roman Baschmakov
    @r.baschmakov_gitlab
    To be specific, the error message says "Multiple semicolon separated statements are unsupported", which is thrown in Sqlite3Connection.cc line 156
    An Tao
    @an-tao
    you should execute SQL statements one by one.
    Roman Baschmakov
    @r.baschmakov_gitlab
    SQLite supports transactions out of the box, see https://www.sqlite.org/c3ref/exec.html
    Drogon does not propagate this support then?
    daz
    @bigg-daz
    Can I assume trantor won't touch the contents of the messageBuffer while the recvMessageCallback runs?
    Specifically for using slices of data I've already retrieved while the callback runs.
    An Tao
    @an-tao

    Can I assume trantor won't touch the contents of the messageBuffer while the recvMessageCallback runs?

    Yes

    daz
    @bigg-daz
    Thank you.
    Ichiro
    @HadesD
    I got an error about trying to use coroutines
    image.png
    how can I fix this for HttpController?
    rajhlinux
    @rajhlinux
    Hello

    Where do I put code for dragon to do some custom automation for the following? :

    Example:
    Client from website presses a button to read some data from the local PostgreSQL database.

    Dragon will listen for requests using websockets.
    Then dragon will parse the JSON data that was requested from client.
    Dragon needs to know what this parsed JSON data request means.
    Parsed JSON data says to fetch some data from local PostgreSQL database.
    After dragon fetches data from local PostgreSQL database, dragon needs to send this fetched data to the client using websocket.

    The above can be easily done using node.js But how can the above objectives be done using dragon?

    Are there any tutorials other than WiKi and docsforge?
    I find WiKi and docsforge a bit too advanced and complicated for a beginner to understand.

    Thanks

    Ichiro
    @HadesD
    @rajhlinux
    your json has fixed structure?
    so you first will have to decode messageString to json, then extract the struct, then work with them, like in nodejs
    rajhlinux
    @rajhlinux
    where do I put the code?
    An Tao
    @an-tao

    how can I fix this for HttpController?

    Use value parameters instead of referance type parameters when using coroutine handlers.

    Ichiro
    @HadesD
    @an-tao
    can you specify how to write in HttpController?
    i'm still don't know how to fix it, sorry
    An Tao
    @an-tao
    @an-tao
    can you specify how to write in HttpController?
    i'm still don't know how to fix it, sorry
        Task<> get(
            HttpRequestPtr req,
            std::function<void(const HttpResponsePtr &)> callback);
    P.R.
    @prothegee
    Hey, @an-tao
    Base on this example, https://drogon.docsforge.com/master/database-general/database-transaction/#one-example
    Where did it happen the rollback when do transaction?
    Rafael Bugajewski
    @rbugajewski
    @prothegee This is stated in the documentation: “The outermost braces are used to limit the scope of the transPtr so that it can be destroyed in time after the execution of sql to end the transaction.”
    That means that a transaction is implicitly defined by the scope.
    P.R.
    @prothegee
    Owh, seems like I distracted by arrow operator. Thank you to make it clear, @rbugajewski
    nobody
    @nobody93
    Just downloaded, built and run the dragon examples, but could not find any example to display background image, nor could find in WiFi, appreciate anyone give an example now to display and run images in a simple example. Thank you very much
    are there any dragon email discussion forum or mailing list for help?
    Rafael Bugajewski
    @rbugajewski
    @nobody93 What exactly do you mean by “displaying background images”? You can certainly use HTML/CSS in the CSP templates, and also combine these with parameters passed in from controllers.
    nobody
    @nobody93
    @rbugajewski, sorry I am new here, is there a demo to use HTML/CSS in the CSP templates? I am learning from drogon/examples currently, could not find an example for it, nor tutorial from WiKi
    nobody
    @nobody93
    Is the ENG 04 1 Controller HttpSimpleController did you refer to? Tried it, but no idea how to complete the code
    I was looking for a simple web application example to display background image and to rotate images automatically in defined time interval.
    nobody
    @nobody93
    According to the WiFi, to run CSP, it should compile with -DCMAKE_ENABLE_EXPORTS=on, but after running it, I could not find dynamic libraries with *.so, what could I be missing?
    Rafael Bugajewski
    @rbugajewski
    @nobody93 I’m not sure what you’re referring to, but you can check out the simple Hello World example, at https://github.com/drogonframework/drogon/blob/master/examples/helloworld/HelloView.csp
    You can add images like in normal HTML documents, see for example https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Img
    And if you want to rotate them in a defined time interval (and automatically display it on the client) you will have to use client-side code in JavaScript, or otherwise reload the whole page, not only redisplay the rotated image.
    P.R.
    @prothegee
    Hello, does anyone know where to get current port access from json listener when domain.tld/foo/bar is been requested?
    An Tao
    @an-tao
    requestPtr->localAddr()
    P.R.
    @prothegee
    requestPtr->localAddr()
    Owh yess, work nicely! Thanks, @an-tao
    Meir Yanovich
    @meiry
    hello all
    i have problem creating new drogon project both windows and linux
    nobody
    @nobody93
    I build with -DCMAKE_ENABLE_EXPORTS=on in ubuntu 18.04, but I could not find dynamic libraries with .so, I only got 2 static libraries libdrogon.a libtrantor.a, how can I build dynamic libraries with .so?
    HadiAbbasi
    @HadiAbbasi

    Hey Guys
    Just a simple question!
    this is a test for me!
    I wanna bind a callback to specific port!
    in other words, I need to make conditions on port numbers to send related response to client that sends request to specific port!
    as you can see, we can just add some listeners having ip , port!
    But addListener method has no any callback args!

    
    drogon::app().addListener("0.0.0.0",20001);
    drogon::app().addListener("0.0.0.0",20002);
    drogon::app().addListener("0.0.0.0",20003);
    
    drogon::HttpAppFramework::instance().registerHandler("/index",
                            [=](const drogon::HttpRequestPtr &req , 
                                std::function<void (const drogon::HttpResponsePtr &)> &&callback)
                            {
                                if (req ->port == 20001)
                                {
                                    auto resp = drogon::HttpResponse::newFileResponse("/path/to/img01.jpg", "", drogon::ContentType::CT_IMAGE_JPG);
                                    callback(resp);
                                }
                                else if (req ->port == 20002)
                                {
                                    auto resp = drogon::HttpResponse::newFileResponse("/path/to/img02.jpg", "", drogon::ContentType::CT_IMAGE_JPG);
                                    callback(resp);
                                }
                                else if (req ->port == 20003)
                                {
                                    auto resp = drogon::HttpResponse::newFileResponse("/path/to/img03.jpg", "", drogon::ContentType::CT_IMAGE_JPG);
                                    callback(resp);
                                }
                            });

    in the top example, req->port has error because req has no any port member!
    so I don't know how can I set conditions or bind callbacks on ports!
    All The Best,
    Hadi

    3 replies
    slaught3red
    @slaught3red:matrix.org
    [m]
    hey guys, could someone please help me out? so i'm having a problem while installing drogon via VCPKG: error: building openssl:x86-windows failed with: BUILD_FAILED. it seems that openssl must be installed as a drogo dependency but [dot]us servers are unreachable for me. so then i manually installed the openssl package but the vcpkg doesn't see it in downloaded folder for some reason. vcpkg list command doesn't seem to detect openssl file too. idk what to do =)