Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • stCky: idk man im just a chat bot
      August 22, 2017, 11:14:52 PM
    • symantec: is this forum
      August 22, 2017, 09:02:56 PM
    • symantec: what the fudge
      August 22, 2017, 09:02:52 PM
    • symantec: I just joined to download datmaker, the links are broken and a user named i nelson i has a fudgeing weird signature
      August 22, 2017, 08:59:33 PM
    • stCky: ur so cool and edgy
      August 22, 2017, 04:15:50 PM
    • Deathspirit: anyways, i'm un ip banned now.. but don't even want to be that at this point lmfao
      August 22, 2017, 01:58:14 PM
    • Deathspirit: now it's some sell out half leeched server :')
      August 22, 2017, 01:57:53 PM
    • Deathspirit: gf moparscape, was the best rsps community i've been on since 2006
      August 22, 2017, 01:57:31 PM
    • stCky: yeah, nah. it's cooked. [link] might help u with a backup or something idk man im just a chat bot
      August 22, 2017, 12:13:25 AM
    • flew420: I sure hope someone has a copy of the forum before it was recked
      August 21, 2017, 11:40:52 PM
    • flew420: O wow i see now, just read thru all the news articles. :(  i've been out of the game for a couple years so coming back to this shit is sad.
      August 21, 2017, 11:39:46 PM
    • flew420: Huh?
      August 21, 2017, 10:49:51 PM
    • stCky: got bought by a russian dude, he put a shitty rsps on it for donations, now no one cares
      August 21, 2017, 10:48:30 PM
    • flew420: I came on for some nostalgic reading in old classic development, and it only goes back to 2014 wtf.
      August 21, 2017, 10:43:09 PM
    • flew420: what happened to this site??
      August 21, 2017, 10:42:36 PM
    • Sean56:[link]
      August 21, 2017, 05:33:45 PM
    • kb010: how can i play? i downloaded the client and it doesnt open.
      August 21, 2017, 10:52:56 AM
    • wodkode: shut it down or fix it
      August 20, 2017, 10:11:28 PM
    • wodkode: dude i cant goto no links on here from google
      August 20, 2017, 10:11:13 PM
    • Dell: Greetings
      August 20, 2017, 11:56:30 AM

    Author Topic: Using NodeJS as a platform  (Read 2337 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 »

    OfflineDeath Style

    • Member
    • ****
    • Posts: 570
    • 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

    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 »

    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: 570
    • 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: 570
    • 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: 570
    • 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: 570
    • 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