Rigner / discord-rpc-java

Java implementation of Discord RPC for rich presence https://github.com/discordapp/discord-rpc
MIT License
25 stars 9 forks source link

Not sending data(no presence info transfered) #18

Open 1-alex98 opened 6 years ago

1-alex98 commented 6 years ago

Data stays in the presenceQueue... image

Because image connection is not correctly established. Code on startup

try{
      discordRpc = new DiscordRpc();
      discordRpc.init(clientProperties.getDiscordConfig().getApplicationId(), discordEventHandler, true, null);
      timer.schedule(new TimerTask() {
        @Override
        public void run() {
          discordRpc.runCallbacks();
        }
      }, initialDelayForCallback, periodForCallBack);
    }catch (Exception e){
      //TODO: report to bugsnap
      log.error("Error in discord init",e);
    }

Code to set presence

  public void updatePlayedGameTo(Game game){
    try {
      DiscordRichPresence discordRichPresence = new DiscordRichPresence();
      discordRichPresence.setState(getDiscordState(game));
      discordRichPresence.setDetails(MessageFormat.format("Game {0}",game.getTitle()));
      discordRichPresence.setStartTimestamp((game.getStartTime()==null?System.currentTimeMillis():game.getStartTime().toEpochMilli())/1000);
      discordRichPresence.setPartyId(String.valueOf(game.getId()));
      discordRichPresence.setPartySize(game.getNumPlayers());
      discordRichPresence.setPartyMax(game.getMaxPlayers());
      if(game.getStatus()==GameStatus.CLOSED){
        discordRichPresence.setEndTimestamp(Instant.now().toEpochMilli()/1000);
      }
      discordRichPresence.setInstance(false);

      discordRpc.updatePresence(discordRichPresence);
    }catch (Exception e){
      //TODO: report to bugsnap
      log.error("Error reporting game status to discord",e);
    }
  }
1-alex98 commented 6 years ago

In updateConnection open is called and state changes to image, but never gets connected Discord is running on my machine

1-alex98 commented 6 years ago

image ready and disconnectd(With message success) from my event handler are called each time I run runCallBacks()