HTTP processing script, ask me about it!

Discussion in 'RGSSx Scripts In Development' started by ??????, Feb 16, 2015.

  1. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,313
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    Hey there,

    As you may/may not know, I have spent the past many many months writing and rewriting and optimizing and then rewriting my HTTP processing system.  (yes, many many rewrites) 

    I am currently in the stage of writing up some good documentation for the system.  Most of the methods are already documented, but I want to ensure that there is more than enough information for those who seek it...

    Anyway, I am currently writing an FAQ for the system, which features classic newb questions such as 'What is HTTP?' and 'How could using HTTP benefit me and my game?'.

    But I want to add more into the documentation, so I ask you fine people to ask me any questions you may have about HTTP and what my system does and whatever else that could be related to these subjects. :)

    Thanks ^_^
     
    #1
    Dreadshadow likes this.
  2. boldpaste2

    boldpaste2 The Dragon Heretics Veteran

    Messages:
    800
    Likes Received:
    441
    First Language:
    English
    Hyper Text Transfer Protocol?
     
    #2
    djDarkX, Dreadshadow and ?????? like this.
  3. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,313
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    Yes :)
     
    #3
  4. Dreadshadow

    Dreadshadow Lv 38 Tech Magician Moderator

    Messages:
    3,840
    Likes Received:
    2,488
    First Language:
    Greek
    Primarily Uses:
    RMMV
    Ok let me shoot you! :p

    So.

    1] Is it client - server based? (Of course it is but it is good for a noob question. You should probably explain the model)

    2] Do you have both scripts for client and server? ( Oh it is just a client that can contact a server (I assume) who supports ruby )

    3] Does it communicate with an Apache server?

    4] Can it communicate with PHP scripts?

    5] Can this support MMO games or is lag an issue?
     
    #4
    ?????? likes this.
  5. UNphiltered_khaos

    UNphiltered_khaos Game Dev. Artist. Veteran

    Messages:
    1,730
    Likes Received:
    640
    Location:
    Montucky
    First Language:
    Americanese
    Primarily Uses:
    N/A
    So...how DOES HTTP benefit my game? I can think of some things I WANT to do, but unsure what this system is capable of...Also, is your HTTP script available?
     
    #5
    ?????? likes this.
  6. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,313
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    1] - The 'client' is the current instance of the game that is connecting you an HTTP server.  For example, if your game is connecting to information on your own website, your game is the client, the website is the server. :)

    2] - I have rewrote the core script a number of times and during that time, have also written some simple addon scripts ~ such as a script that determines the game client ip address and location and another script to autoupdate game files ;)

    3] - It could yes.  I personally use it with an Abyss web server on my laptop and also with my real website host via ipage.com. :)

    4] - Yep, thats the main point ~ to have your game interact with php scripts and SQL databases on your own server.

    5] - Not at this time, but depending on the success/popularity of the system, I may be tempted to continue working towards such a goal.

    Also, this depends on your personal definition of 'mmo games'. It would be possible to code a system for players to battle each other, but probably not for having 500 players on the same map having ABS style pvp battles ~ at least not until other restrictions of RM have been lifted, such as the rendering of graphics vs the processing of game logic (ie, the game loop functionality that is hidden in either the game exe or the dll)

    You can use HTTP within your own games to provide features that are widely considered 'online features'.  

    Using HTTP, it is extremely possible to have one players game interact with another players game. For example, sending mail from one player to another,

    or even player trades... Additionally, HTTP could be used in conjunction with additional systems to create a peer 2 peer gaming environment. (that is not something it can do right now, nor is it my intention to do so at this time)

    This being said, the features that are possible is a completely different thing from the features you are able to apply yourself. The more experienece you have with writing code, the better. :)

    And no, it has not yet been released. I'm just finishing up documentation and ensuring everything is nice and clean, then I will have a think abut how i want to release it and when. :)
     
    #6
    Dreadshadow likes this.
  7. Dreadshadow

    Dreadshadow Lv 38 Tech Magician Moderator

    Messages:
    3,840
    Likes Received:
    2,488
    First Language:
    Greek
    Primarily Uses:
    RMMV
    Dekita, what you make sounds fantastic. Really!

    It isn't noob friendly, hell you need to know what you are about to do, but STILL this is great!

    Hope it will finish soon to check it out.

    Also... about security... is there any? :p

    I know this is a killing question. :p
     
    #7
  8. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,313
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    Yea, it really isnt newb friendly, but I am trying to provide enough documentation so that even newbs, providing they can read, should be able to benefit from the use of the system(s).  And I've also written a few 'sample' systems to go along with the main system, so people can see how to use it correctly. :)

    Ummm... Define 'security' ? ;)

    I mean, it can perform POST requests, which would help hide any HTTP request paths from miscellaneous hacking techniques, but if someone can get into your game and see the code, it would leave your server vulnerable <- providing the hacker knew how to manipulate your server data, this could be very bad.
     
    #8
    Dreadshadow likes this.
  9. Dreadshadow

    Dreadshadow Lv 38 Tech Magician Moderator

    Messages:
    3,840
    Likes Received:
    2,488
    First Language:
    Greek
    Primarily Uses:
    RMMV
    Yeah security is really a state of mind. That's how I define it.

    What I am really asking is: 

    Is it possible to implement advanced encryption methods, like digital signature for authentication and strong encryption methods to pass sensitive data hard to be decrypted?

    Let's say you make a game that a server unites 5 players in a unified world.

    So no lag.

    But each player must have an account to play the game.

    So you register online. To the website.

    Then you start your client.

    To enter the game you should provide username and password.

    Can your script implement anti man-in-the-middle-attack measures?

    Cause sensitive data are sensitive. 
     
    Last edited by a moderator: Feb 16, 2015
    #9
    ?????? likes this.
  10. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,313
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    Yes, it is possible to compress/encode the information being sent in various ways, such as zlib. It is also possible to setup proxy servers and whatever else :)

    Note: I have not tried, nor do plan to (at east not a proxy), any of these, but the possibility is there, just gotta define how you wanna encrypt the data before the request is processed ~ which I have been working very hard to make as easy as possible. ;)

    Well, lag is all relative.  The clients internet connection, your servers processing power, other crap going on in the background of your cpu can all affect the phenomenon known as 'lag'... 

    During my own tests, I have been sending a request to my localhost server (Abyss Web Server ~ offline server, thus, cutting out most of the server transmission delays) and reading the reply every frame (60 times per second). During this time I have not seen so much as a flicker of a frame or anything that would suggest lag to be a major problem, but that being said...

    In order to have, for example, 5 players exploring in some cave you would need the following...

    1 - a means of obtaining the player ~ done (can easily generate a unique user code for the player, or use their ip address against them ;) )

    2 - a means of holding the party information ~ it is possible that this could be done using php and SQL servers; however, the processes involved currently elude me.

    I mean, could have some SQL database that holds information on the current games 'online party list', where each element is an ip address or specific user id. Then, you have your database also hold information on the current 'online players party member actions'. 

    then, in your game, you update the players online party member list thing, this gets the information of the other users and from there, you just have to transfer what the other user is doing to your own sql database, and then, re-read the data back into your game ~ thus, friend players character moves around in your game. :p

    ^ that, could become quite laggy, depending on how everything is handled.
     
    #10
    Dreadshadow likes this.
  11. Dreadshadow

    Dreadshadow Lv 38 Tech Magician Moderator

    Messages:
    3,840
    Likes Received:
    2,488
    First Language:
    Greek
    Primarily Uses:
    RMMV
    Yes. lag depends deeply on the database architecture, structure and in which normal form it is. :p

    Even on localhost a bad designed database will destroy the whole project.

    It seems you are preparing a really neat piece of code!
     
    #11
  12. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,313
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    oh yea, I have learned from my initial database structure that the approach i was taking just wasn't viable, so I changed it up a little.

    There is currently a few modules that can be included within other modules and classes to easily process http logic for your game's systems. I just have to create a dedicated error handling class and finish the documentation and its all done.  Its a huge pain trying to reproduce all these random http errors :/

    Additionally, should one wish to create an instance of an HTTP session, connection or request to allow the control over the request procedure, its already available. :)

    Furthermore, performing an http request is easy as hell. Here is an example...

    http_request = { pswzServerName: "www.mysite.com", pwszObjectName: "/MyPreciousFilePath/MyPhpScript.php",    pwszHeaders: "Content-Encoding: deflate",    dwHeadersLength: 1, }reply = HTTP::request(http_request) # < returns reply from server, encoded.Zlib::Inflate::inflate(reply)And like, thats for an encoded request with headers. , a basic request would be much more simple. :D
     
    #12
    Dreadshadow likes this.
  13. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,640
    Likes Received:
    2,966
    Location:
    Philippines
    First Language:
    Tagalog
    Well for starters, I do want to know the answers to these questions

     
    #13
    ?????? likes this.
  14. erpicci

    erpicci Villager Member

    Messages:
    29
    Likes Received:
    21
    First Language:
    Italian
    First question I can think of is why using a TCP-based protocol (such as HTTP) instead of an UDP-based one? Indeed the ability to easily talk to a webserver is a big pro, just wondering whether there are other reasons.

    Secondly, from the piece of script you posted, it seems that HTTP requests are synchronous... correct? Do you have a timeout mechanism to prevent game freezing in case the synchronization phase fails?

    Does this support both HTTP/1.0 and HTTP/1.1?

    Does this support HTTPS? (I think the answer should be clear from above comments, but maybe it is something you would like to add to a FAQs section)

    Can you get connection-speed information at gametime (like latency)?

    Some stats may also be interesting to check out.

    Good luck for this project! Wondering whether you are looking for volountieers to try it and/or help with documentation/statistics?
     
    #14
    ?????? likes this.
  15. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,313
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    @Engr. - (copy and paste from my faq

       
      Q: What is HTTP??
      A: The Hypertext Transfer Protocol (HTTP) is an application protocol for
         distributed, collaborative, hypermedia information systems. HTTP is the
         foundation of data communication for the World Wide Web.
         
         Hypertext is structured text that uses logical links (hyperlinks) between
         nodes containing text. HTTP is the protocol to exchange/transfer hypertext.
         
         See: http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
         for additional information on HTTP and its functionality.
         
         In simple terms, HTTP allows one computer to interact with an online
         presence, whether that be another client server or a website is purely
         based on the competency of your code writing team.
         
         
         
      Q: How could HTTP benefit me, and my RPG Maker project?
      A: You can use HTTP within your own games to provide features that are widely
         considered as 'online features'.
         
         Using HTTP, it is extremely possible to have one players game interact with
         another players game. For example, sending mail from one player to another,
         or even player trades...
         
         Additionally, HTTP could be used in conjunction with additional systems to
         create a peer 2 peer gaming environment.
         
         This being said, the features that are possible is a completely different
         thing from the features you are able to apply yourself.
         The more experienece you have with writing code, the better.


    @erpici - Awesome questions btw. ^_^

    "First question I can think of is why using a TCP-based protocol (such as HTTP) instead of an UDP-based one?"

    The reason for this is purely because when I first began researching how to transmit data online, all the immediate suggestions where for TCP, so hat is what I began to research. :p

    That being said, I have been looking into UDP more and more, so who knows, I may eventually write some kind of UDP based transmission of data. :)

    "Secondly, from the piece of script you posted, it seems that HTTP requests are synchronous... correct? Do you have a timeout mechanism to prevent game freezing in case the synchronization phase fails?"

    Yes, the example I posted above is using regular synchronization. I am currently testing and making sure that asyncronous requests also work ~ having lil issue with the callback, but ill get it eventually.  But yes, there is the ability to set the timeout for your request. ^_^

    "Does this support both HTTP/1.0 and HTTP/1.1? Does this support HTTPS?"

    Not tried with 1.0, but it should.  The dll it interacts with does support 1.0.  Obviously, I use 1.1 and it works fine.  And yes HTTPS is available. ^_^

    "Can you get connection-speed information at gametime (like latency)? Some stats may also be interesting to check out."

    Not tried tbh. Certainly possible ~ ill read up on how such information is normally attained.  Probably possible to just timecheck before the request, and then timecheck after, - old from new = ping. :p

    "Good luck for this project! Wondering whether you are looking for volunteers to try it and/or help with documentation/statistics?"

    Thanks, I've been working really hard trying to figure all this crap out for years now :D

    And I suppose, that would depend on what kinda help people can offer :p
     
    #15
    Engr. Adiktuzmiko likes this.
  16. gRaViJa

    gRaViJa Veteran Veteran

    Messages:
    739
    Likes Received:
    267
    Location:
    Belgium
    First Language:
    Dutch
    Can you use it to extract a variable from the game (a high score for example) and save it in a mysql database?

    Can you use it to build a global high score system within the game itself?
     
    #16
  17. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,313
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    Yes and yes. :)
     
    #17
  18. erpicci

    erpicci Villager Member

    Messages:
    29
    Likes Received:
    21
    First Language:
    Italian
    Other non-trivial questions I thought of:

    Whether a tool is going to be used for conformance checking against [things like] RFC2616

    Support for parallel connections

    Optional tunable parameters (like some window size, or things for the underlying TCP level)

    I don't know about "people", but this cyborg would love to contribute, in fact. I can help with code (expecially C), documentation, translation... or if you need a softer help, just benchmarks/statistics when the product is ready. Or other things, depending on what needs to be done.

    In any case, good luck for this project! Network is definitively something missing in RPG Maker.
     
    #18
    ?????? likes this.
  19. gRaViJa

    gRaViJa Veteran Veteran

    Messages:
    739
    Likes Received:
    267
    Location:
    Belgium
    First Language:
    Dutch
    I know :p But I thought these are some questions more people mighy have, so it could be in your FAQ?
     
    #19
  20. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,264
    Likes Received:
    2,313
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    @erpicci - Dude, you know too much. :D

    What are you doing lurking around RPG Maker forums with kinda knowledge of networking?

    I must say though, your question has confused me slightly...

    "Optional tunable parameters (like some window size, or things for the underlying TCP level)" <- TCP objects dont uhh, have a window... ;)

    If you mean are you able to create an instance of, for example, an 'HTTP::Request' object, then yes, you are ~ from there there is many means of controlling the actual object and one could (if desired) create a subclass of HTTP::Request with additional logic and use their own subclass for performing the actual request. 

    "Support for parallel connections" <- You can create an instance of a 'HTTP::Connect' object (the HTTP connection) and store it in some variable to use at [x] point in time for performing whatever request.  It is possible to create more than one connection object. :)

    "Whether a tool is going to be used for conformance checking against [things like] RFC2616" -< Not sure what you mean about a 'tool'.  I wasnt planning on including any external tools for anything.  I'm trying to keep everything pure ruby (except for the windows dll calls obviously) -> Even sat for days at a time trying to figure out how to convert C code into ruby ~ however, I am still fighting with whether it would be best to use 'pure ruby' or whether i would be best  :D

    Anyway, could you elaborate a little on what you mean with this one?

    And yea, networking in RM is something that could have made a lot of games, a whole lot better ~ and would have also saved me years of my life... but anyway. How are you with the conversion of C types into ruby format?  like, would you be able to construct some C type in ruby successfully? *fingers crossed* lol


    @gravija ~ yea, i knew you knew, which is why i kept the answer short n sweet :p

    I was gonna copy and reply the answers from my FAQ, but I dont wanna post that until the system is just about to be released :D
     
    #20

Share This Page