> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# chat_manager::add_local_user

> chat_manager::add_local_user

# chat\_manager::add\_local\_user

ローカル chat\_manager インスタンスにローカル ユーザーを追加します。

## 構文

```cpp theme={null}
chat_user* add_local_user(  
    PCWSTR xboxUserId  
)  
```

### パラメーター

*xboxUserId*   \_In\_\
型: PCWSTR

追加するローカル ユーザーの XBOX ユーザー ID。

### 戻り値

型: chat\_user\*

## 解説

Game Chat 2 インスタンスに追加されるすべてのローカル ユーザーは、まず [XUserAddAsync](/reference/system/xuser/functions/xuseraddasync) で追加する必要があります。

ローカルおよびリモート ユーザーの合計数が chat\_manager::initialize() で指定された最大ユーザー数と等しくない限り、ユーザーは無条件に追加されます。

戻り値は、このユーザーに関連付けられた chat\_user オブジェクトへのポインターです。XBOX ユーザー ID が無効な場合、ユーザーの chat\_indicator 値は game\_chat\_user\_chat\_indicator::platform\_restricted になります。

典型的なパターンは次のようになります:

```cpp theme={null}
chat_user* newLocalChatUser = chat_manager::singleton_instance().add_local_user(&amp;lt;local_user_xuid&amp;gt;);

size_t chatUserCount; 
chat_user_array chatUsers; 
chat_manager::singleton_instance().get_remote_chat_users(&chatUserCount, &chatUsers); 
for (uint32_t chatUserIndex = 0; chatUserIndex < chatUsercount; ++chatUserIndex) 
{ 
    chat_user* chatUser = chatUsers[chatUserIndex]; 
    game_chat_communication_relationship_flags relationship = game_chat_communication_relationship_flags::none; 
    if (chatUser can send and receive to/from newLocalChatUser) 
    { 
        relationship = c_communicationRelationshipSendAndReceiveAll; 
    } 
    else if (chatUser can send to newLocalChatUser) 
    { 
        relationship = c_communicationRelationshipSendAll; 
    } 
    else if (chatUser can receive from newLocalChatUser) 
    { 
        relationship = c_communicationRelationshipReceiveAll; 
    } 

    newLocalChatUser->set_communication_relationship(chatUser, relationship); 
} 
```

## 要件

**ヘッダー:** GameChat2.h

**サポートされるプラットフォーム:** Windows、XBOX One ファミリ本体および XBOX Series 本体

## 関連項目

[chat\_manager](/reference/chat/gamechat2/classes/chat_manager/chat_manager)\
[chat\_user](/reference/chat/gamechat2/classes/chat_user/chat_user)\
[chat\_manager::add\_remote\_user](/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_add_remote_user)\
[chat\_manager::remove\_user](/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_remove_user)


## Related topics

- [chat_manager::get_chat_users](/ja-jp/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_get_chat_users.md)
- [chat_manager::add_remote_user](/ja-jp/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_add_remote_user.md)
- [chat_manager::remove_user](/ja-jp/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_remove_user.md)
- [chat_user::local](/ja-jp/reference/chat/gamechat2/classes/chat_user/methods/chat_user_local_function_2.md)
- [chat_user_local::speech_to_text_conversion_preference_enabled](/ja-jp/reference/chat/gamechat2/classes/chat_user/chat_user_local/methods/chat_user_local_speech_to_text_conversion_preference_enabled.md)
