RobCoIndustries / pipboy

:beginner: Experimental pipboy Desktop app for Fallout 4
BSD 3-Clause "New" or "Revised" License
61 stars 7 forks source link

Implement server selection #29

Open rgbkrk opened 8 years ago

rgbkrk commented 8 years ago

Users should be able to select a server if more than one is available. Color can be the default green for the server selection since we don't know it yet (and don't have a local store).

luckydonald commented 8 years ago

How does we get a server list? From what i picked up at discover.js we need something like

import createDiscovery from 'pipboylib/connection/createDiscovery'

var servers = createDiscovery();

servers.subscribe(function(newServer) {
    $("#serverlist").add("<div>").text(newServer);  // i know this is jquery, but I am desperate now.
});

with createDiscovery being something like a generator we know from python, right?

luckydonald commented 8 years ago

I also don't quite understand how this would communicate me, that a server is now gone again.

luckydonald commented 8 years ago

Another question: Should we be able to display multiple pip boys (= multiple windows) in the same app? Starting multiple processes with the whole browser runtime doubled for this kinda would suck...

kitten commented 8 years ago

@luckydonald If we change the observable to discover games over time with an interval we can also group the messages that we get back. We group them and thus would receive lists of the available server for each discovery

luckydonald commented 8 years ago

@philplckthun how long should we wait?

So somethin like this, except there probably is already some function in RxJS

var serverList = [];
while (dontStop) {
   var newServer = server.getSomeServer();
   serverList.append(newServer);
   if (nextIntervall == now) {
      observer.onNext(serverList);  // this does send, right? // python: yield serverList
      serverList = [];
   }
}

also if that happens in the lib, we should keep the waitless version somewhere too. And forgive me, i am thinking with python generators portals

Edit just saw the sweet

.bufferWithTime(10000)

at #22

rgbkrk commented 8 years ago

Starting multiple processes with the whole browser runtime doubled for this kinda would suck...

It's only one browser runtime with the Electron App, so long as they're just new Windows this isn't a problem. As for if we should do it, I'm not sure of the utility of having multiple pipboys on one screen for multiple games.

how long should we wait?

Re-triggering the probe after some time makes a good amount of sense, since we're working over UDP. The Fallout 4 server only responds once per broadcast and it's fairly quick. We could/should bump the TTL for the UDP packets as well to make sure that we're able to discover all the PCs and PS4s on a given local network (jokingly, making for dorm room or shared wifi tomfoolery).

luckydonald commented 8 years ago

And I found reactivex -> Interval

var source = Rx.Observable
    .interval(500 /* ms */) 
    .timeInterval() // not sure what that does opposed to interval above

With this it should be possible to let this call the server search and emission the results somehow