Jack-Flux / node-opskins-trade

JavaScript SDK for Trade.OPSkins' HTTP API
https://trade.OPSkins.com
2 stars 3 forks source link

offerUpdated and pollData #5

Closed herenickname closed 6 years ago

herenickname commented 6 years ago

https://github.com/Jack-Flux/node-opskins-trade/blob/4358b84fc89f1a965463f57bb602cdbc4ddde966/index.js#L38

You can more efficiently use the resources, saving not all the offer, but only its state.

this.pollData[offer.id] = offer.state

===== And on last npm version of module, seems not worked offerUpdated event... After sending offer to user and accepting by him I dont got any new events in offerUpdated

herenickname commented 6 years ago
    offers.forEach((offer) => {
      if (offer.id in this.pollData) {
        if (this.pollData[offer.id] != offer.state) {
          this.emit('offerUpdated', offer);
          delete this.pollData[offer.id];
        }
        return;
      }
      this.pollData[offer.id] = offer.state;
      this.emit('newOffer', offer);
    });
Jack-Flux commented 6 years ago

Should be working now, thanks for the feedback