Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • hexedss1: Anyone would like to help on client side got a variable declartion Error
      August 15, 2018, 09:06:30 PM
    • SOUPSOUP: just get a vpn
      August 13, 2018, 06:44:28 PM
    • jme: _^_ will answer all of your javascript questions
      August 12, 2018, 07:11:00 PM
    • doomsale: and where is boxman?
      August 10, 2018, 03:16:59 AM
    • doomsale: Where can i play the Moparscape MMORPG with the Metallica instrumentals?
      August 10, 2018, 03:16:47 AM
    • doomsale: no longer clicking on doors and dummies at east bank
      August 10, 2018, 03:16:07 AM
    • doomsale: were all grown up now huh?
      August 10, 2018, 03:15:58 AM
    • _^_: hey everyone look at my graphs [link]
      August 06, 2018, 01:52:16 PM
    • braedyn: Someone pl0x help me out with PI Lottery!!
      August 03, 2018, 02:12:25 AM
    • Travas: p3n1s
      July 26, 2018, 09:46:33 PM
    • Krackkid: You up :eggplant:
      July 23, 2018, 06:18:17 PM
    • DeathsChaos9: no
      July 23, 2018, 03:53:31 PM
    • Emulous: Come check out Emulous: [link]
      July 22, 2018, 03:37:19 PM
    • Emulous:[link]
      July 22, 2018, 03:37:00 PM
    • Travas: ur mom
      July 21, 2018, 06:04:50 PM
    • YNRDAB: Watcha big ballers up too?
      July 20, 2018, 11:01:06 AM
    • dark250: i need help for coding client
      July 19, 2018, 08:27:37 AM
    • Travas: yes
      July 14, 2018, 02:19:44 PM
    • drubrkletern: lmao racist and sexist much?
      July 14, 2018, 01:11:52 PM
    • Cole1497: yeah i got you lil boat give me a second
      July 13, 2018, 03:19:35 AM

    Author Topic: Using NodeJS as a platform  (Read 2932 times)

    0 Members and 1 Guest are viewing this topic.

    Offlinesini

    • Member
    • ****
    • *
    • *
    • Posts: 5,785
    • Thanks: +0/-0
      • View Profile
    Using NodeJS as a platform
    « on: September 02, 2014, 12:48:28 AM »
    Anyone thought to use NodeJS for a server? I think it would be a great platform to use. You could technically split apart your services across multiple services. Eg: Control of a world to a RESTful service.

    I thought about it the other idea and most servers (because RSPS isn't as massive as say enterprise applications) don't follow master/slave model. Even sharding/clustering. I think that'd be interesting to design :)
    « Last Edit: September 02, 2014, 12:50:17 AM by sinisoul »
    Runescape Gambling

    OfflineDeath Style

    • Member
    • ****
    • Posts: 569
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #1 on: September 02, 2014, 01:13:22 AM »
    I was writing one a few months ago and finished the login server but couldn't figure out how to do player updating and now I waste my days away posting on this forum

    aside from that setback it uses Express/Sinatra's routing paradigm and would be very easy to add modules if I ever got past that barrier

    I actually looked on google first and found someone on rune-server attempted the same but was dismissed by a bunch of idiots who thought it was a bad idea because it wasn't multithreaded
    Runescape Gambling

    Offlinesini

    • Member
    • ****
    • *
    • *
    • Posts: 5,785
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #2 on: September 02, 2014, 02:01:56 AM »
    « Last Edit: September 02, 2014, 02:08:40 AM by sinisoul »
    Runescape Gambling

    OfflineHcoJustin

    • Member
    • ****
    • Posts: 2,400
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #3 on: September 02, 2014, 02:07:47 AM »
    Peterbjornx was working on one a while ago. You'd get more info out of him than anyone here could provide I think. AFAIK node has a way to spawn child processes and communicate between the two, so we can cluster certain aspects of the game.

    Offlinesini

    • Member
    • ****
    • *
    • *
    • Posts: 5,785
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #4 on: September 02, 2014, 02:10:21 AM »
    Peterbjornx was working on one a while ago. You'd get more info out of him than anyone here could provide I think. AFAIK node has a way to spawn child processes and communicate between the two, so we can cluster certain aspects of the game.

    Just use a unix socket. When I think of cluster I think of a server cluster. That's another topic of conversation I touched on but didn't have any response to :( I think the word 'dictate' is better.

    Be my think tank Moparscape. :}
    « Last Edit: September 02, 2014, 02:17:03 AM by sinisoul »

    OfflineDeath Style

    • Member
    • ****
    • Posts: 569
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #5 on: September 02, 2014, 02:41:28 AM »
    I know how node works, I was just referencing the ignorance toward it in general

    I can't think of an intensive calculation that would block other than player scanning

    Offlinesini

    • Member
    • ****
    • *
    • *
    • Posts: 5,785
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #6 on: September 02, 2014, 02:55:03 AM »
    I wouldn't even call that an intensive calculation but more of an intensive search haha. Just because of how many players, and you have to do it for each player so at worst you have to do 2000x2000 iterations.

    Diagram!:
    « Last Edit: September 02, 2014, 02:57:10 AM by sinisoul »

    OfflineLothy

    • Member
    • ****
    • *
    • *
    • Posts: 7,006
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #7 on: September 02, 2014, 05:27:00 AM »
    Even static space partitioning (e.g.: simple region systems that split the cartesian co-ordinates up into 32x32 square sections) offers better than O(n) performance. It might not be quite as efficient as the quad tree but the implementation is simple.

    Simpler still, you could sort players using a comparator that orders them by their x and y co-ordinates (something like x << 16 | y).
    In a world that is 10x10 cartesian points, and a search that looks up to d=2 from the player, you would loop through the points like so:
    o o o d d d d o o o o
    o o o d d d d o o o o
    o o o d d d d o o o o
    o o o d d d d d o o o
    o o o d d d d d o o o
    o o o d d P d d o o o
    o o o d d d d d o o o
    o o o d d d d d o o o
    o o o o d d d d o o o
    o o o o d d d d o o o
    o o o o d d d d o o o


    In this example the 'o' tiles are not iterated through, the 'd' tiles are iterated through, and the 'P' tile represents the player. Algorithmically this is simple - you piggyback off the existing sorting functionality of an ordered data structure (a NavigableMap, such as the TreeMap<T> class) using a trivial comparator (based on x << 16 | y or y << 16 | x).


    Mind you, this discussion re: NodeJS and RESTful services etc isn't worth having in my opinion. At the end of the day nobody has the infrastructure to bother with scalability. If they did have the financing for that sort of setup then they would be subject to legal proceedings.
    « Last Edit: September 02, 2014, 05:29:13 AM by Lothy »
    <&Speljohan_> i wouldnt want to live in a society where Mopman isnt monitored 24/7

    Offlinesini

    • Member
    • ****
    • *
    • *
    • Posts: 5,785
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #8 on: September 02, 2014, 05:40:56 AM »
    Interesting. Never thought it like that.

    OfflineLothy

    • Member
    • ****
    • *
    • *
    • Posts: 7,006
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #9 on: September 02, 2014, 05:58:36 AM »
    It'd work reasonably well if the distribution of entities is pretty uniform I think. But even if it's not optimal, it's the most trivial implementation I've managed to think of.
    You simply resort the TreeMap each tick after updating positions but before performing player searches. The downside is you have the memory overhead of the tree structure - but it's probably negligible. The resorting each game tick should be pretty cheap too as it's always a partially sorted tree.

    Maybe profile these solutions? Comparing them over 1000, 10k, 100k and 1m entities would make for an interesting read.
    <&Speljohan_> i wouldnt want to live in a society where Mopman isnt monitored 24/7

    OfflineRSCShadow

    • Member
    • ****
    • Posts: 2,024
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #10 on: September 02, 2014, 12:59:31 PM »
    I have a semi-functioning RSC server written for NodeJS. It isn't very efficient at all, but I liked exploring ideas on how to structure things.

    EDIT: To Lothy, you don't theoretically even need a tick system. You could write the entire server with events.
    « Last Edit: September 02, 2014, 01:03:27 PM by RSCShadow »

    OfflineLothy

    • Member
    • ****
    • *
    • *
    • Posts: 7,006
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #11 on: September 02, 2014, 04:12:09 PM »
    Well having the game tick serves as a means of keeping everything in sync. If you had an event-based system then you'd still need to apply some kind of timing check each time you received a packet to ensure someone wasn't doing too much in too little time.
    With that in mind, it's actually easier (I think) to operate within the context of a 600ms game tick (or some other consistent timing).

    Does that make sense?


    EDIT: And I just want to clarify the example above. You don't iterate through tiles -- you iterate through players that are on those tiles. So in practice, unless you're unfortunate enough to be vertically in line with a high-population section of the game (e.g.: Falador market place) you iterate through very few players.
    « Last Edit: September 02, 2014, 04:18:02 PM by Lothy »
    <&Speljohan_> i wouldnt want to live in a society where Mopman isnt monitored 24/7

    Offlinesini

    • Member
    • ****
    • *
    • *
    • Posts: 5,785
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #12 on: September 02, 2014, 04:33:47 PM »
    https://github.com/laverdet/node-fibers/

    ? ?_? ?? Fibers ? ?_? ??

    You could theoretically just query different information every 600 ms from the world server (if per say its a RESTful service) then send the packets back. I honestly have decoupled the binary protocol from the other HTTP  services because I feel like since most of the Runescape binary protocol is obfuscated it'd be easier to have a single server interface that dealt with that.
    « Last Edit: September 02, 2014, 04:46:23 PM by sinisoul »

    OfflineMethod

    • Member
    • ***
    • *
    • Posts: 168
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #13 on: September 02, 2014, 07:59:30 PM »
    Simpler still, you could sort players using a comparator that orders them by their x and y co-ordinates (something like x << 16 | y).
    In a world that is 10x10 cartesian points, and a search that looks up to d=2 from the player, you would loop through the points like so:
    o o o d d d d o o o o
    o o o d d d d o o o o
    o o o d d d d o o o o
    o o o d d d d d o o o
    o o o d d d d d o o o
    o o o d d P d d o o o
    o o o d d d d d o o o
    o o o d d d d d o o o
    o o o o d d d d o o o
    o o o o d d d d o o o
    o o o o d d d d o o o

    If you're looking for players within 2 tiles of 'P', why not just look at the 5x5 square centered at 'P'? I'm not sure I follow why the other 'd' tiles are examined.
    :-)

    OfflineDeath Style

    • Member
    • ****
    • Posts: 569
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #14 on: September 02, 2014, 10:18:01 PM »
    you could just maintain an array of entities

    Code: [Select]
    coordinate[x][y] = [player, player, player]
    then just scan n tiles around the player's coordinate

    doesn't sound efficient but I don't know how slow it would be to iterate over empty elements

    Offlinesini

    • Member
    • ****
    • *
    • *
    • Posts: 5,785
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #15 on: September 02, 2014, 10:28:21 PM »
    THIS ISNT A TOPIC OF DISCUSSION OF ALGORITHMS BUT A TOPIC OF PLATFORMS TYVM

    OfflineDeath Style

    • Member
    • ****
    • Posts: 569
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #16 on: September 02, 2014, 10:35:56 PM »
    I think it's a good platform (I'm using it) but I'd be wary about attempting it if you don't have a large JS background

    I'd make sure you're writing it in harmony though
    « Last Edit: September 02, 2014, 10:37:47 PM by Death Style »

    Offlinesini

    • Member
    • ****
    • *
    • *
    • Posts: 5,785
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #17 on: September 02, 2014, 10:40:21 PM »
    I think it's a good platform (I'm using it) but I'd be wary about attempting it if you don't have a large JS background

    I'd make sure you're writing it in harmony though

    I don't feel like JS is too difficult to comprehend especially if you're familiar with the functional paradigm. Coffeescript makes things even easier coming from a Ruby background ^___^

    OfflineDeath Style

    • Member
    • ****
    • Posts: 569
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #18 on: September 02, 2014, 10:42:20 PM »

    Offlinesini

    • Member
    • ****
    • *
    • *
    • Posts: 5,785
    • Thanks: +0/-0
      • View Profile
    Re: Using NodeJS as a platform
    « Reply #19 on: September 02, 2014, 10:50:42 PM »
    fudgeing burn javascripts stupid ass prototype with fire.

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal