CTR Pia  4.11.3
Game Communication Engine
inet_NexUpdateSessionSetting.h
1 /*---------------------------------------------------------------------------*
2  Project: Pia
3  File: inet_NexUpdateSessionSetting.h
4 
5  Copyright Nintendo. All rights reserved.
6 
7  These coded instructions, statements, and computer programs contain
8  proprietary information of Nintendo of America Inc. and/or Nintendo
9  Company Ltd., and are protected by Federal copyright law. They may
10  not be disclosed to third parties or copied or duplicated in any form,
11  in whole or in part, without the prior written consent of Nintendo.
12  *---------------------------------------------------------------------------*/
13 
14 
15 #pragma once
16 
17 #include <pia/session/session_UpdateSessionSetting.h>
18 #include <pia/inet/inet_NexSessionTypes.h>
19 
20 #if NN_PIA_CTR
21 #pragma diag_suppress 1300 //n1769: Pragma for ARMCC.
22 #endif
23 #include <nex.h>
24 #if NN_PIA_CTR
25 #pragma diag_warning 1300 //n1769: Pragma for ARMCC.
26 #endif
27 
28 namespace nn
29 {
30 namespace pia
31 {
32 namespace inet
33 {
34 /*!
35  @brief Base class that manages information specific to updating session conditions.
36  @details Only the settings of the value specified for the update are updated. No specification is needed for settings that are not being updated.
37 
38  @date 2015-03-20 Added APIs to set parameters for scored matchmaking.
39  @date 2014-01-21 Initial version.
40 */
42 {
43 public:
44 /*!
45  @brief The default constructor.
46 */
48 
49 /*!
50  @brief The destructor.
51 */
52  virtual ~NexUpdateSessionSetting();
53 
54 /*!
55  @brief Specifies the session type for the session.
56  @details Updates are only possible from <tt>inet::SESSION_TYPE_FRIEND</tt> to <tt>inet::SESSION_TYPE_ANYBODY</tt>.
57  @param[in] sessionType Specifies the session type.
58 */
59  void SetSessionType(SessionType sessionType);
60 /*!
61  @brief Gets the specified session type.
62  @return Returns the specified session type.
63 */
65 
66 /*!
67  @brief Specifies the description string for the session.
68  @param[in] description The description string.
69 */
70  void SetDescription(const wchar_t* description);
71 /*!
72  @brief Gets the specified description string.
73  @return Returns the specified description string.
74 */
75  const wchar_t* GetDescription() const;
76 
77 /*!
78  @cond PRIVATE
79  @brief Sets attributes for the session.
80  @param[in] index Specifies the index of the attribute for the session.
81  @param[in] value Specifies the value of the attribute for the session.
82 */
83  //void SetAttribute(u32 index, u32 value);
84  //! @endcond
85 
86 /*!
87  @brief Sets attributes for the session.
88  @param[in] attributes Specifies an array of attributes.
89 */
90  //void SetAttribute(u32 index, u32 value);
92 /*!
93  @brief Gets the specified attribute.
94  @param[in] index Specifies the index for the attribute to get.
95  @return Returns the specified attribute value.
96 */
97  u32 GetAttribute(u32 index) const;
98 
99 /*!
100  @brief Sets application-defined data.
101  @details Specify a size that does not exceed <tt>inet::APPLICATION_DATA_BUFFER_MAX_SIZE</tt>.
102  @param[in] pData Specifies a pointer to the buffer for the application-defined data for the session.
103  @param[in] size Specifies the size of the application-defined data for the session.
104  @return Returns a <tt>Result</tt> value indicating success if the application-defined data is set successfully.
105 
106  @retval nn::pia::ResultInvalidArgument Indicates that either the buffer pointer was <tt>NULL</tt> or the specified data size was too big. Programming error. Fix your program so that this error is not returned.
107 */
108  nn::Result SetApplicationData(const u8* pData, size_t size);
109 /*!
110  @brief Gets specified application-defined data.
111  @param[in] pDataBuf Specifies a pointer to a buffer from which to copy the specified application-defined data.
112  @param[in] pDataSize Specifies the size of the data written to the copy buffer.
113  @param[in] dataBufSize Specifies the copy buffer size.
114  @return Returns a <tt>Result</tt> value indicating success if the application-defined data is acquired successfully.
115 
116  @retval nn::pia::ResultInvalidArgument Indicates that either the buffer pointer is <tt>NULL</tt> or the pointer returned by the copied size is <tt>NULL</tt>. Programming error. Fix your program so that this error is not returned.
117  @retval nn::pia::ResultInvalidState Indicates that no application-defined data is set. Programming error. Fix your program so that this error is not returned.
118  @retval nn::pia::ResultBufferShortage Indicates that the set application-defined data cannot be copied because it is greater in size than the buffer. Programming error. Fix your program so that this error is not returned.
119 */
120  nn::Result GetApplicationData(u8* pDataBuf, size_t* pDataSize, size_t dataBufSize) const;
121 
122 /*!
123  @brief Sets whether participation in this session is possible.
124 
125  @details Specifies whether the session can be joined.
126 
127  @param[in] isOpen Specifies whether the session updated by this <tt>NexUpdateSessionSetting</tt> function is joinable. Set to <tt>true</tt> to enable.
128 */
129  void SetOpenParticipation(bool isOpen);
130 
131 /*!
132  @cond PRIVATE
133  @brief Gets whether participation in this session is possible.
134 
135  @return Returns <tt>true</tt> if the session is joinable.
136 */
137  bool GetOpenParticipation() const;
138  //! @endcond
139 
140 /*!
141  @brief Sets the user password.
142 
143  @details Specifies the session's user password for the session.
144 
145  @param[in] pUserPassword Specifies the user password.
146  @param[in] passwordLength Specifies the string length of the user password.
147 */
148  void SetSessionUserPassword(const wchar_t* pUserPassword, size_t passwordLength);
149 
150 /*!
151  @cond PRIVATE
152  @brief
153 */
154  const wchar_t* GetSessionUserPassword() const;
155  //! @endcond
156 
157 /*!
158  @brief Specifies the matchmaking priority when a session with the same requirements is found.
159 
160  @details Specifies the matchmaking priority for the new session.
161  Enabled only when searches are performed with
162  <tt>nn::pia::inet::SELECTION_METHOD_BROADEN_RANGE_WITH_SELECTION_PRIORITY</tt> and <tt>nn::pia::inet::SELECTION_METHOD_SCORE_BASED</tt>.
163  If a value that exceeds <tt>nn::pia::inet::SESSION_MAX_SELECTION_PRIORITY</tt> is provided as an argument, <tt>nn::pia::inet::SESSION_MAX_SELECTION_PRIORITY</tt> is set instead.
164 
165  @param[in] priority Specifies the matchmaking priority.
166 */
167  void SetSelectionPriority(u8 priority);
168 
169 /*!
170  @brief Sets the minimum number of participants for the session.
171  @param[in] min Specifies the minimum number of participants for the new session.
172 */
173  void SetMinParticipants(u16 min);
174 
175 /*!
176  @brief Gets the specified minimum number of participants.
177  @return Returns the minimum number of participants.
178 */
179  u16 GetMinParticipants() const;
180 
181 /*!
182  @brief Sets the maximum number of participants for the session.
183  @param[in] max Specifies the maximum number of participants for the new session.
184 */
185  void SetMaxParticipants(u16 max);
186 
187 /*!
188  @brief Gets the maximum number of participants.
189  @return Returns the maximum number of participants.
190 */
191  u16 GetMaxParticipants() const;
192 
193 /*!
194  @brief Updates the rating value to use for comparison during <tt>nn::pia::inet::SELECTION_METHOD_SCORE_BASED</tt>.
195  @param[in] ratingValue Specifies the rating value.
196 */
197  void SetRatingValue(u32 ratingValue);
198 /*!
199  @cond PRIVATE
200 */
201  u32 GetRatingValue() const;
202  bool IsSetRatingValue() const;
203  //! @endcond
204 
205 /*!
206  @brief Updates the disconnection rate to use for comparison during <tt>nn::pia::inet::SELECTION_METHOD_SCORE_BASED</tt>.
207  @details We recommend using NEX's <tt>MatchmakeReferee</tt> feature.
208  @param[in] disconnectionRate Specifies the disconnection rate.
209 */
210  void SetDisconnectionRate(u32 disconnectionRate);
211 /*!
212  @cond PRIVATE
213 */
214  u32 GetDisconnectionRate() const;
215  bool IsSetDisconnectionRate() const;
216  //! @endcond
217 
218 /*!
219  @brief Updates the violation rate to use for comparison during <tt>nn::pia::inet::SELECTION_METHOD_SCORE_BASED</tt>.
220  @details We recommend using NEX's <tt>MatchmakeReferee</tt> feature.
221  @param[in] violationRate Specifies the violation rate.
222 */
223  void SetViolationRate(u32 violationRate);
224 /*!
225  @cond PRIVATE
226 */
227  u32 GetViolationRate() const;
228  bool IsSetViolationRate() const;
229  //! @endcond
230 
231 /*!
232  @brief Updates the country code to use for comparison during <tt>nn::pia::inet::SELECTION_METHOD_SCORE_BASED</tt>.
233  @details Sets the country code to use when you have configured to not use location information with <tt>UseGeoIP()</tt> or when you have configured to use that location information but it was not available.
234  The specified country code is not used when location information is available.
235  When a country code is not set, and when you have configured to not use location information with <tt>UseGeoIP()</tt> or when you have configured to use that location information but it was not available, the default value is used as the score for comparing country codes.
236  @param[in] countryCode Specifies the country code.
237 */
238  void SetNintendoCountryCode(u32 countryCode);
239 /*!
240  @cond PRIVATE
241 */
242  u32 GetNintendoCountryCode() const;
243  bool IsSetNintendoCountryCode() const;
244  //! @endcond
245 
246 /*!
247  @brief Sets the IP address to use for getting a distance over the Internet during <tt>nn::pia::inet::SELECTION_METHOD_SCORE_BASED</tt>.
248  @param[in] b Specifies whether to update <tt>GeoIp</tt>.
249 */
250  void SetUpdateGeoIp(bool b);
251 
252 /*!
253  @cond PRIVATE
254  @brief Gets whether to update <tt>GeoIp</tt>.
255 
256  @return Specifies whether to update <tt>GeoIp</tt>.
257 */
258  bool GetUpdateGeoIp() const;
259  //! @endcond
260 
261 /*!
262  @cond PRIVATE
263 */
264  bool IsSetScoreBaseParam() const;
265  //! @endcond
266 
267 /*!
268  @cond PRIVATE
269  @brief Gets the matchmaking priority.
270 
271  @details Gets the matchmaking priority for the session.
272 
273  @return Returns the matchmaking priority.
274 */
275  u8 GetSelectionPriority() const;
276  //! @endcond
277 
278 /*!
279  @cond PRIVATE
280  @brief Updates the header information that indicates the usage state of the application-defined data region.
281 */
282  void UpdateApplicationDataHeader(const u8* pData, size_t dataSize);
283  //! @endcond
284 
285 /*!
286  @cond PRIVATE
287  @brief Gets data from the application-defined data.
288 */
289  void GetApplicationDataInternal(void* pVectorTmp) const;
290  //! @endcond
291 
292 /*!
293  @cond PRIVATE
294  @brief Copies the application-defined data.
295 */
296  void CopyApplicationDataToVector(void* pVectorTmp) const;
297  //! @endcond
298 
299 /*!
300  @cond PRIVATE
301  @brief Copies the application-defined data.
302 */
303  u32 GetModificationFlag() const;
304  //! @endcond
305 
306  void Reset();
307 
308  // Prints information that is useful for debugging.
309  void Trace(u64 flag) const;
310 
311  // SetApplicationBuffer
312  // OpenParticipate
313 
314 protected:
315  u32 m_ModificationFlag;
316 
317  SessionType m_SessionType;
318 
319  u16 m_MinParticipants;
320  u16 m_MaxParticipants;
321 
322  // The description string.
323  wchar_t m_Description[DESCRIPTION_DATA_BUFFER_MAX_SIZE + 1];
324 
325  // Attributes.
326  u32 m_Attribute[ATTRIBUTE_MAX_SIZE];
327 
328  u8 m_ApplicationDataBuffer[APPLICATION_DATA_BUFFER_MAX_SIZE_INTERNAL];
329  size_t m_ApplicationDataSize;
330  size_t m_ApplicationDataInternalOffset;
331 
332  bool m_OpenParticipation;
333 
334  u8 m_ProgressScore;
335 
336 #if NN_PIA_NEX_NEW_FEATURE_FOR_MATCHMAKE
337  // Pointer to the user password that is configured for the session.
338  wchar_t m_UserPassword[nn::pia::inet::SESSION_USER_PASSWORD_LENGTH + 1];
339 #endif
340 
341  // Scored parameters.
342  u32 m_RatingValue;
343  bool m_IsSetRatingValue;
344 
345  u32 m_DisconnectionRate;
346  bool m_IsSetDisconnectionRate;
347 
348  u32 m_ViolationRate;
349  bool m_IsSetViolationRate;
350 
351  u32 m_CountryCode;
352  bool m_IsSetCountryCode;
353 
354  bool m_IsUpdateGeoIp;
355 
356 private:
357  // The copy constructor is sealed.
359 
360  // The assignment operator is sealed.
362 
363 /*!
364  @cond PRIVATE
365  @brief Adds a change flag to the locations that changed.
366 */
367  void AddModificationFlag(u32 bit);
368  //! @endcond
369 };
370 }
371 }
372 } // End of namespace nn::pia::inet.
void SetAttributes(u32 attributes[nn::pia::inet::ATTRIBUTE_MAX_SIZE])
Sets attributes for the session.
void SetOpenParticipation(bool isOpen)
Sets whether participation in this session is possible.
void SetDisconnectionRate(u32 disconnectionRate)
Updates the disconnection rate to use for comparison during nn::pia::inet::SELECTION_METHOD_SCORE_BAS...
const size_t ATTRIBUTE_MAX_SIZE
The number of attributes that can be specified in a session.
Definition: inet_NexSessionTypes.h:39
const wchar_t * GetDescription() const
Gets the specified description string.
void SetRatingValue(u32 ratingValue)
Updates the rating value to use for comparison during nn::pia::inet::SELECTION_METHOD_SCORE_BASED.
Definition: assert.h:115
virtual ~NexUpdateSessionSetting()
The destructor.
void SetSessionType(SessionType sessionType)
Specifies the session type for the session.
void SetMinParticipants(u16 min)
Sets the minimum number of participants for the session.
void SetMaxParticipants(u16 max)
Sets the maximum number of participants for the session.
NexUpdateSessionSetting()
The default constructor.
Base class that manages information specific to updating session conditions.
Definition: inet_NexUpdateSessionSetting.h:41
u16 GetMinParticipants() const
Gets the specified minimum number of participants.
const u32 SESSION_USER_PASSWORD_LENGTH
The user password&#39;s string length.
Definition: inet_NexSessionTypes.h:52
void SetNintendoCountryCode(u32 countryCode)
Updates the country code to use for comparison during nn::pia::inet::SELECTION_METHOD_SCORE_BASED.
void SetUpdateGeoIp(bool b)
Sets the IP address to use for getting a distance over the Internet during nn::pia::inet::SELECTION_M...
void SetDescription(const wchar_t *description)
Specifies the description string for the session.
Base class that manages settings specific to session criteria updates.
Definition: session_UpdateSessionSetting.h:30
SessionType
Enumerates the session types.
Definition: inet_NexSessionTypes.h:78
SessionType GetSessionType() const
Gets the specified session type.
u32 GetAttribute(u32 index) const
Gets the specified attribute.
void SetSelectionPriority(u8 priority)
Specifies the matchmaking priority when a session with the same requirements is found.
u16 GetMaxParticipants() const
Gets the maximum number of participants.
nn::Result GetApplicationData(u8 *pDataBuf, size_t *pDataSize, size_t dataBufSize) const
Gets specified application-defined data.
void SetViolationRate(u32 violationRate)
Updates the violation rate to use for comparison during nn::pia::inet::SELECTION_METHOD_SCORE_BASED.
nn::Result SetApplicationData(const u8 *pData, size_t size)
Sets application-defined data.
void SetSessionUserPassword(const wchar_t *pUserPassword, size_t passwordLength)
Sets the user password.