room_chat
room_chat Sample
Overview
The room_chat sample is an interactive command-line program that demonstrates the Room Chat features of the Diarkis server. It allows users to join a room and exchange custom chat messages in real time, as well as retrieve the full chat history via a sync command.
The room_chat sample showcases the following features:
Joining a Room
Sending custom chat messages to Room members
Retrieving the full chat history (sync)
Leaving a Room
Starting the Server in Your Local Environment
Execute the tutorial to start the server used in the sample and launch the Diarkis server in your local environment
Sample Arguments
Specify the following 3 parameters when launching the sample.
serverAddr
Specify the endpoint of the Diarkis server
UID
Specify the user ID to connect with as any string
clientKey
Specify the client key as any string
Launch example:
Explanation of the room_chat Sample
Initialize the Diarkis runtime and Diarkis Module and connect to the Diarkis server. For more details, refer to Overall Flow for Using Diarkis Module.
Initialize the Room module using the Diarkis Module.
Join a Room using RandomJoin. DiarkisRoomBase::RandomJoinRoom() will join an existing Room if available, or create a new one if not. After sending a request to the server, check the status with DiarkisRoomBase::IsJoin() until the Room join is complete.
Once joined, the sample enters an interactive command loop. The user can type commands via stdin to interact with the room:
/send/<message> — Send a chat message to the room
/sync — Retrieve the full chat history from the server. Results are printed via the OnRoomChatLog callback.
/quit — Leave the room and exit the program
/help — Show available commands
Execute DiarkisRoomBase::SendLeaveRoom() to request to leave the Room. In this sample, wait until leaving the Room is complete using DiarkisRoomBase::IsLeave().
Demo complete
For more details, refer to Overall Flow for Using Diarkis Module.
Notes
On Windows, the sample sets the console to UTF-8 encoding to correctly handle Japanese and other multibyte characters in chat messages.
Multiple clients can be run simultaneously from separate terminal windows to test room chat interactions.
The /sync command retrieves the full chat history from the server. Results are displayed via the OnRoomChatLog callback.
最終更新
役に立ちましたか?

