Results 1 to 13 of 13
  1. #1
    Atroxide's Avatar
    Join Date
    Mar 2014
    Gender
    male
    Posts
    5
    Reputation
    10
    Thanks
    0

    XMLHttpRequest() (or similar) in Realm Relay for requesting JSON from a web server?

    I am looking for the ability to request external content from within a Realm-Relay script. I have a personal API running on a web server and is outputting in JSON format and I am looking for ways to connect to this file online and use this data from within the script.

    I have tried using XMLHttpRequest() but it didn't work (as it is not included within SpiderMonkey JS) so is there any ways to achieve this? If it isn't possible to achieve this with Realm-Relay, what is another way I can go about doing this?
    Last edited by Atroxide; 03-16-2014 at 08:19 AM.

  2. #2
    mSteaker's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Posts
    127
    Reputation
    14
    Thanks
    59
    Code:
    public static String getUrlSource(String url) throws IOException {
    		URL yahoo = new URL(url);
    		URLConnection yc = yahoo.openConnection();
    		BufferedReader in = new BufferedReader(new InputStreamReader(
    				yc.getInputStream(), "UTF-8"));
    		String inputLine;
    		StringBuilder a = new StringBuilder();
    		while ((inputLine = in.readLine()) != null)
    			a.append(inputLine);
    		in.close();
    
    		return a.toString();
    	}

  3. #3
    Atroxide's Avatar
    Join Date
    Mar 2014
    Gender
    male
    Posts
    5
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by Wetish View Post
    Code:
    public static String getUrlSource(String url) throws IOException {
    		URL yahoo = new URL(url);
    		URLConnection yc = yahoo.openConnection();
    		BufferedReader in = new BufferedReader(new InputStreamReader(
    				yc.getInputStream(), "UTF-8"));
    		String inputLine;
    		StringBuilder a = new StringBuilder();
    		while ((inputLine = in.readLine()) != null)
    			a.append(inputLine);
    		in.close();
    
    		return a.toString();
    	}
    Ahh so its not possible with just RealmRelay?

  4. #4
    CrazyJani's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    2,475
    Reputation
    170
    Thanks
    15,666
    Quote Originally Posted by Atroxide View Post
    Ahh so its not possible with just RealmRelay?
    Realm Relay is made with java, that code is made with java. Think what could be the connection between these two

  5. #5
    Atroxide's Avatar
    Join Date
    Mar 2014
    Gender
    male
    Posts
    5
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by CrazyJani View Post
    Realm Relay is made with java, that code is made with java. Think what could be the connection between these two
    I appreciate the help and I apologize for the delayed response but I am kind of stuck on how to use the function.

    I wasn't sure if the function you were giving me was already apart of RR or not so I looked through the Devoid's repo and I found no mention of it. However, from what I can, this isn't actually the current version of RR as Devoid is no longer active and QuickNick has taken over the project but I couldn't find QuickNick's repo nor any type of change log to see if this would be one of the changes he made.

    If you are providing me this function to put inside of RR, where can I get the latest source code of RR that QuickNick released?

    Thanks.

    EDIT: I tried decompiling (with two different decompilers) the code and recompiling with the new function but get errors when assigning new packet ids on launch.

  6. #6
    DeVoidCoder's Avatar
    Join Date
    Oct 2013
    Gender
    male
    Posts
    105
    Reputation
    10
    Thanks
    702
    The relay scripts cannot do normal IO or web requests for security reasons. It protects the users and prevents the creation of malicious scripts.

  7. #7
    CrazyJani's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    2,475
    Reputation
    170
    Thanks
    15,666
    Quote Originally Posted by DeVoidCoder View Post
    The relay scripts cannot do normal IO or web requests for security reasons. It protects the users and prevents the creation of malicious scripts.
    We weren't talking about the scripts were we?

  8. #8
    DeVoidCoder's Avatar
    Join Date
    Oct 2013
    Gender
    male
    Posts
    105
    Reputation
    10
    Thanks
    702
    Quote Originally Posted by CrazyJani View Post
    We weren't talking about the scripts were we?
    Yes we were; did anyone read the OP?
    Quote Originally Posted by Atroxide View Post
    I am looking for the ability to request external content from within a Realm-Relay script. I have a personal API running on a web server and is outputting in JSON format and I am looking for ways to connect to this file online and use this data from within the script.

  9. #9
    CrazyJani's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    2,475
    Reputation
    170
    Thanks
    15,666
    Quote Originally Posted by DeVoidCoder View Post
    Yes we were; did anyone read the OP?
    I just checked that @Wetish posted java code so I thought we weren't, haha

  10. #10
    mSteaker's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Posts
    127
    Reputation
    14
    Thanks
    59
    I thought you were editing Realm Relay itself since you talked about trying XMLHttpRequest(). Sorry

  11. #11
    Atroxide's Avatar
    Join Date
    Mar 2014
    Gender
    male
    Posts
    5
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by Wetish View Post
    I thought you were editing Realm Relay itself since you talked about trying XMLHttpRequest(). Sorry
    Haha, all is fine. XMLHttpRequest() is a function available for JavaScript in web browsers but is lacking from SpiderMonkey which is the JavaScript engine that RealmRelay uses.

    As for editing RR itself, that is very much an option but I can't seem to find the source of a working RealmRelay. DeVoidCoder's version doesn't work and I can't seem to find the source or a changelog for QuickNick's re-release of it. I would very much appreciate some help in getting a hold of the source of a working RR or getting a changelist of what all changes would need to occur for DeVoidCoder's version to work again.

  12. #12
    mSteaker's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Posts
    127
    Reputation
    14
    Thanks
    59
    Quote Originally Posted by Atroxide View Post
    Haha, all is fine. XMLHttpRequest() is a function available for JavaScript in web browsers but is lacking from SpiderMonkey which is the JavaScript engine that RealmRelay uses.

    As for editing RR itself, that is very much an option but I can't seem to find the source of a working RealmRelay. DeVoidCoder's version doesn't work and I can't seem to find the source or a changelog for QuickNick's re-release of it. I would very much appreciate some help in getting a hold of the source of a working RR or getting a changelist of what all changes would need to occur for DeVoidCoder's version to work again.
    I think the only thing you need to change is the packet ids. Make a new xml with the correct ids and upload it somewhere. Then change the url in the GETXmlParse class to your updated one.

  13. #13
    Atroxide's Avatar
    Join Date
    Mar 2014
    Gender
    male
    Posts
    5
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by Wetish View Post
    I think the only thing you need to change is the packet ids. Make a new xml with the correct ids and upload it somewhere. Then change the url in the GETXmlParse class to your updated one.
    Yep. compiled and running fine with it updated!

    Thanks for the help. If I get the time, ill update the repo to use a user-defined source for the XML data URL that way RR is not reliant on any single-user but instead can be taken over by any person willing to host the file without the JAR being actually reliant on them.

    This topic can be marked as Solved now.
    Last edited by Atroxide; 03-18-2014 at 03:15 PM.

Similar Threads

  1. [TUTORIAL] REALM RELAY FOR NEWBS
    By harsh1412 in forum Realm of the Mad God Tutorials & Source Code
    Replies: 3
    Last Post: 03-26-2014, 03:02 AM
  2. [Outdated] Realm Relay v1.1.0 - Proxy for RotMG 19.1
    By DeVoidCoder in forum Realm of the Mad God Hacks & Cheats
    Replies: 285
    Last Post: 02-17-2014, 11:45 AM
  3. Realm-Relay v1.1.0 temp fix for connecting to busy servers
    By zekikez in forum Realm of the Mad God Tutorials & Source Code
    Replies: 1
    Last Post: 01-25-2014, 07:33 AM
  4. Realm Relay disable hp/mp/other notifications for other players
    By fuckyoutwo in forum Realm of the Mad God Tutorials & Source Code
    Replies: 9
    Last Post: 01-13-2014, 02:56 PM
  5. [Outdated] Realm Relay v1.0.0 - Proxy for RotMG 17.2
    By DeVoidCoder in forum Realm of the Mad God Hacks & Cheats
    Replies: 126
    Last Post: 10-17-2013, 10:23 PM