ECode NetworkIdentitySet::WriteToStream( /* [in] */ IDataOutput* out) { VALIDATE_NOT_NULL(out); out->WriteInt32(VERSION_ADD_NETWORK_ID); Int32 size; GetSize(&size); out->WriteInt32(size); AutoPtr<IIterator> iter; GetIterator((IIterator**)&iter); while (Ptr(iter)->Func(iter->HasNext)) { AutoPtr<INetworkIdentity> ident = INetworkIdentity::Probe(Ptr(iter)->Func(iter->GetNext)); Int32 type; ident->GetType(&type); out->WriteInt32(type); Int32 subtype; ident->GetSubType(&subtype); out->WriteInt32(subtype); String subscriberId; ident->GetSubscriberId(&subscriberId); WriteOptionalString(out, subscriberId); String networkId; ident->GetNetworkId(&networkId); WriteOptionalString(out, networkId); Boolean roaming; ident->GetRoaming(&roaming); out->WriteBoolean(roaming); } return NOERROR; }
ECode NetworkIdentitySet::WriteToStream( /* [in] */ IDataOutput* out) { VALIDATE_NOT_NULL(out); out->WriteInt32(VERSION_ADD_NETWORK_ID); out->WriteInt32(GetSize()); HashSet< AutoPtr<INetworkIdentity> >::Iterator it; for(it = Begin(); it != End(); ++it) { AutoPtr<INetworkIdentity> ident = *it; Int32 type; ident->GetType(&type); out->WriteInt32(type); Int32 subtype; ident->GetSubType(&subtype); out->WriteInt32(subtype); String subscriberId; ident->GetSubscriberId(&subscriberId); WriteOptionalString(out, subscriberId); String networkId; ident->GetNetworkId(&networkId); WriteOptionalString(out, networkId); Boolean roaming; ident->GetRoaming(&roaming); out->WriteBoolean(roaming); } return NOERROR; }
size_t JsonWriteRichPresenceObj(char* dest, size_t maxLen, int nonce, int pid, const DiscordRichPresence* presence) { JsonWriter writer(dest, maxLen); { WriteObject top(writer); JsonWriteNonce(writer, nonce); WriteKey(writer, "cmd"); writer.String("SET_ACTIVITY"); { WriteObject args(writer, "args"); WriteKey(writer, "pid"); writer.Int(pid); if (presence != nullptr) { WriteObject activity(writer, "activity"); WriteOptionalString(writer, "state", presence->state); WriteOptionalString(writer, "details", presence->details); if (presence->startTimestamp || presence->endTimestamp) { WriteObject timestamps(writer, "timestamps"); if (presence->startTimestamp) { WriteKey(writer, "start"); writer.Int64(presence->startTimestamp); } if (presence->endTimestamp) { WriteKey(writer, "end"); writer.Int64(presence->endTimestamp); } } if ((presence->largeImageKey && presence->largeImageKey[0]) || (presence->largeImageText && presence->largeImageText[0]) || (presence->smallImageKey && presence->smallImageKey[0]) || (presence->smallImageText && presence->smallImageText[0])) { WriteObject assets(writer, "assets"); WriteOptionalString(writer, "large_image", presence->largeImageKey); WriteOptionalString(writer, "large_text", presence->largeImageText); WriteOptionalString(writer, "small_image", presence->smallImageKey); WriteOptionalString(writer, "small_text", presence->smallImageText); } if ((presence->partyId && presence->partyId[0]) || presence->partySize || presence->partyMax) { WriteObject party(writer, "party"); WriteOptionalString(writer, "id", presence->partyId); if (presence->partySize && presence->partyMax) { WriteArray size(writer, "size"); writer.Int(presence->partySize); writer.Int(presence->partyMax); } } if ((presence->matchSecret && presence->matchSecret[0]) || (presence->joinSecret && presence->joinSecret[0]) || (presence->spectateSecret && presence->spectateSecret[0])) { WriteObject secrets(writer, "secrets"); WriteOptionalString(writer, "match", presence->matchSecret); WriteOptionalString(writer, "join", presence->joinSecret); WriteOptionalString(writer, "spectate", presence->spectateSecret); } writer.Key("instance"); writer.Bool(presence->instance != 0); } } } return writer.Size(); }