RobCoIndustries / pipboy

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

(Re)connect #22

Open luckydonald opened 8 years ago

luckydonald commented 8 years ago

Starting it besides (and before) a fullscreen running Fallout is difficult, as it doesn't seem to retry connecting...

update: Steps we need implemented:

(Just tick them when done.)

rgbkrk commented 8 years ago

We also need to catch when it's connected yet a pipboy is not available yet.

luckydonald commented 8 years ago

Also if the connection breaks. Not sure if that is handled. edit: implemented with #31

luckydonald commented 8 years ago

I think it would be great if it could display everything even without connection.

So you already load all the components, but have a (re-/dis-)connect button somewhere. Until connection it would use some cached data, like the mobile app does. Before first caching, without data use the default values

luckydonald commented 8 years ago

Steps we need implemented:

[moved to top post]

luckydonald commented 8 years ago

I digged a bit in the code. I believe we need to check on the onerrors in pipboylib.connection.createDiscovery:24 or pipboylib.connection.createDiscovery:40

This must be possible somehow!

kitten commented 8 years ago

@luckydonald Nope, those errors are just for the discovery. These are btw emitted on the observable, which completes after that. So for example an RxJS observable works like this:

Next => Next => Next => Complete

in our case we might want to complete the observable ourselves to end the discovery. On an error it might looks like this:

Next => Next => Error => Complete

We actually atm use the pipboylib promise wrapper that transforms this discovery observable into a promise that just emits a single server.

The errors that should send us back to the server selection are actually here: https://github.com/RobCoIndustries/pipboylib/blob/master/src/decoding/createObservable.js

rgbkrk commented 8 years ago

I tinkered with this last night and wasn't really sure how I'd get the disposable from the subscribe.

let d = createDiscovery()
  .bufferWithTime(500)
  .first()
  .subscribe(servers => {
    // stuff
  });

// can't dispose this until completion

Seems like it autodisposes somehow though?

> var d = pbl.connection.createDiscovery().bufferWithTime(500).first().subscribe(function(s) { console.log(s) }); d
AutoDetachObserver {
  isStopped: false,
  observer:
   AnonymousObserver {
     isStopped: false,
     _onNext: [Function],
     _onError: [Function],
     _onCompleted: [Function] },
  m:
   { isDisposed: false,
     current: AutoDetachObserver { isStopped: false, observer: [Object], m: [Object] } } }
> [ { IsBusy: false,
    MachineType: 'PS4',
    info: { address: '192.168.1.71', family: 'IPv4', port: 28000, size: 50 } } ]

> d
AutoDetachObserver {
  isStopped: true,
  observer:
   AnonymousObserver {
     isStopped: true,
     _onNext: [Function],
     _onError: [Function],
     _onCompleted: [Function] },
  m: { isDisposed: true, current: null } }
kitten commented 8 years ago

@rgbkrk This observable in particular is being disposed because it completed. Once an observable sequence is complete there is no need to keep it around. In this case you've used .first() which auto-completes the sequence after the first(n = 1) events.

rgbkrk commented 8 years ago

@luckydonald worth pointing you towards RxJS, what we're using under the covers for pipboylib.

rgbkrk commented 8 years ago

@philplckthun Ok, sweet. I'll be using this then later this evening!

luckydonald commented 8 years ago

Above I was actually speaking of the discover & connect to game process, which doesn't seem to happen except on app startup. Played Fallout a while, the connection text just stayed there, nothing happened. With android I could discover it fine the whole time.

kitten commented 8 years ago

@luckydonald We just have to send the discovery payload multiple times, I guess, as long as there's a subscriber

luckydonald commented 8 years ago

like window.setIntervall(doItAgain, 10*1000 ) ?

kitten commented 8 years ago

@luckydonald Yea, but inside the observable.

luckydonald commented 8 years ago

@philplckthun so inside the library? Wont that break existing code? Also I'd throw into the discussion: constant every 10 seconds (not that wait-longer-on-fail nonsense)

luckydonald commented 8 years ago

There was some nice diagram in gitter which outlines the connection process 2015-12-16-12.19.17.jpg

luckydonald commented 8 years ago

To better test the discovery locally, there is NimVek/pipboy (python) capable to simulate the PC app. $ python pipboy.py PipBoy: start starts the server PipBoy: stop stop the server It tends to crash sometimes, just stop and start again. That should make testing discovery easier, so you don't have to unplug your PS4 every time.

luckydonald commented 8 years ago

Bump. Edit: Meanwhile I'll try the PyPipboyApp (github)

rgbkrk commented 8 years ago

That's ok, sorry we haven't been working on it. Got pulled in for some other work in my free time. Thanks for pinging @luckydonald.