Getting Content from Webserver

Discussion in 'Plugin Development' started by MolaynoxX, Jun 8, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    MolaynoxX

    Hi,
    I wanna get some content from a php script on my webserver but i cant get this working.
    I already tried htmlparser but this lead to laggs while a player joined.
    So now i am searching for a method to get a value from this url.

    Sorry for my bad english and thanks for everyone who try to helps me.
     
  2. Offline

    Rafiki2085

    I don't really know what you are after, but I would have your webserver talk to a SQL database, and then have the plug-in read from that database.
     
  3. Offline

    MolaynoxX

    The problem is, that the MySQL Database of the forum doesn't allow connections from outside.
    So i have to use a php script as bridge between this database and my plugin.
     
  4. Offline

    Giant

    I take it the server and the script are not on the same server? In this case, the data lag is normal, as you are making a request to a different server, which always has some latency. Add to this the speed of your database, and the number of connections at once, and lag might increase quite a bit...
     
  5. Offline

    Rafiki2085

    I don't think I can help you then... Sorry
     
  6. do you need the data direct on join, or may it be some seconds later alivable good to?
     
  7. Offline

    MolaynoxX

    I dont need it at join, i also used a repeating task but this lead to laggs too.
     
  8. I recommend getting the information on an delayed Ascry task, and then passes the data to an delayed Scry task, so you can edit blocks or players whitout to worry whit bukkit thread thing
     
  9. Offline

    Lolmewn

    Or you can just setup the MySQL server to take connections from outside.
     
  10. Code:java
    1.  
    2. final String playerName = ...;
    3. Bukkit.getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable()
    4. {
    5. @Override
    6. public void run()
    7. {
    8. String name = playerName; // So you can use name inside the url
    9. URL url = null;
    10. final Object content = url.getContent();
    11. Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
    12. {
    13. @Override
    14. public void run()
    15. {
    16. Object contantFromUrl = content;
    17. // Use bukkit things here
    18. }
    19. });
    20. }
    21. });[/yntax]
     
  11. Offline

    MolaynoxX

    Thanks it's working now.
     
Thread Status:
Not open for further replies.

Share This Page