Skip to content
This repository was archived by the owner on Apr 8, 2019. It is now read-only.
This repository was archived by the owner on Apr 8, 2019. It is now read-only.

Not sending data(no presence info transfered) #18

@1-alex98

Description

@1-alex98

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);
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions