public static RichPresence SetRichPresence( RichPresence presence, string applicationID, int port = 6463) { try { RichPresence response; return(WebRPC.TrySetRichPresence(presence, out response, applicationID, port) ? response : (RichPresence)null); } catch (Exception ex) { throw; } }
public static bool TrySetRichPresence( RichPresence presence, out RichPresence response, string applicationID, int port = 6463) { if (presence != null) { if (presence.HasSecrets()) { throw new BadPresenceException("Cannot send a presence with secrets as HTTP endpoint does not suppport events."); } if (presence.HasParty() && presence.Party.Max < presence.Party.Size) { throw new BadPresenceException("Presence maximum party size cannot be smaller than the current size."); } } for (int port1 = port; port1 < 6472; ++port1) { using (WebClient webClient = new WebClient()) { try { WebRequest webRequest = WebRPC.PrepareRequest(presence, applicationID, port1); webClient.Headers.Add("content-type", "application/json"); if (WebRPC.TryParseResponse(webClient.UploadString(webRequest.URL, webRequest.Data), out response)) { return(true); } } catch (Exception ex) { } } } response = (RichPresence)null; return(false); }