HowToUsePlugin.md
Table of Contents
Installation Instructions
1. Import Unity Package
Import the DiarkisUnityPlugin.unitypackage
into your target project.
2. Configure Connection Information
Select Assets/Diarkis/Prefabs/DiarkisNetworkManager
and display the DiarkisNetworkManager
script in the Inspector.
Next, click on the item labeled Transport
to display its contents, and configure the connection information to Diarkis as follows:
Setting Item | Role | Example Input |
---|---|---|
HttpHost | Value of EndPoint URL | asia-northeast1.diarkis.io/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX |
ClientKey | Value of Client Key | XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX (Can be empty) |
3. Place the Prefab in the Scene
Place the configured DiarkisNetworkManager
prefab into the scene.
Ensure that AutoStartConnect
is checked (it is on by default), and click the play button at the top of the editor.
This will automatically initiate the connection to the Diarkis server.
How to Use the Plugin
Setting Up the DiarkisNetworkManager Prefab
DiarkisNetworkManager
is a crucial class responsible for the connection to Diarkis and must be placed in the scene.
The main settings are as follows:
Setting Item | Role |
---|---|
Transport.HttpHost | Value of EndPoint URL |
Transport.ClientKey | Value of Client Key |
Transport.AutoRetryTimes | Number of retry attempts in case of connection failure |
AutoStartConnect | Whether to automatically start connection to Diarkis server |
IsWaitDisconnectOnAppQuit | Whether to wait for the disconnection process to complete when the app is closed |
WaitDisconnectTime | Maximum time to wait for the above process. If exceeded, the app will forcibly close |
Requesting Network Connection & Disconnection
To connect (or disconnect) to the Diarkis network, call the functions through DiarkisNetworkManager
.
Receiving Network Connection & Disconnection Responses
Responses from the server can be received as events.
First, add a component that triggers events to the scene.
Add an appropriate GameObject
to the scene and attach the DiarkisCoreEventCallback
component to it.
This component allows you to register functions, which will be triggered in response to event occurrences.
Create a class to register functions as follows:
Attach this script to an appropriate GameObject
, and register the functions you want to be called upon event occurrence to DiarkisCoreEventCallback
.
In this way, you can receive responses from the server.
Utilizing Various Modules
Diarkis includes the following modules:
Module Name | Corresponding Event Component |
---|---|
|
|
|
|
|
|
|
|
|
|
To send data, call the corresponding functions of each module.
To receive data, place the corresponding event components in the scene and register functions to them.
As an example, let's create a new room using the Room
module.
Sending Requests from the Room Module
The following code uses the Room
module to create a new room.
Receiving Responses from the Room Module
First, attach the DiarkisRoomEventCallback
to an appropriate GameObject
placed in the scene.
Then, create a class to receive events as follows:
Finally, place this script in the scene and register the function to DiarkisRoomEventCallback
's OnRoomCreate
.
This allows you to receive the results when Room.Create
is called.
While the Room
module has been taken as an example here, the usage of other modules is similar.
Feature Reference
Core Features
Namespace | Diarkis |
Class Name | DiarkisNetworkManger |
Access Method | DiarkisNetworkManger.Instance |
Interface Representing Events | IDiarkisCoreEvent |
Event Component for Unity | DiarkisCoreEventCallback |
Property List (Core)
Property | Role |
---|---|
UID | UID that uniquely identifies this client |
Modules | Various modules (Room, Group, Field...) |
Method List (Core)
Method | Role |
---|---|
IsConnected | Whether the network is connected |
Connect | Connect to the network |
Disconnect | Disconnect from the network |
Event List (Core)
Event | Role |
---|---|
OnNetworkConnect | Connected to the network |
OnNetworkDisconnect | Disconnected from the network |
OnNetworkException | Exception occurred during communication |
OnNetworkOffline | Preparing to shut down the server |
OnApplicationWantsToQuit | Trying to close the application |
Room Features
Namespace | Diarkis.Modules |
Class Name | DiarkisRoom |
Access Method | DiarkisNetworkManger.Instance.Modules.Room |
Interface Representing Events | IDiarkisRoomEvent |
Event Component for Unity | DiarkisRoomEventCallback |
Property List (Room)
Property | Role |
---|---|
IsJoined | Whether joined in Room |
RoomID | Room ID |
OwnerUID | UID of the room owner |
MemberUIDs | UIDs of the members (including oneself & room owner) |
Method List (Room)
Method | Role |
---|---|
Create | Create a room |
Join | Join a room |
JoinRandom | Join a room randomly |
Leave | Leave a room |
GetOwnerID | Get the ID of the room owner |
GetMemberIDs | Get the IDs of the room members |
Broadcast | Send data to the entire room |
BroadcastTo | Send data to a specified room |
MessageTo | Send data to a specified member |
SyncObjects | Get the current state of objects |
UpdateObject | Add, update, or delete an object |
UpdateProperties | Update the properties of a room |
GetProperties | Get the properties of a room |
IncrProperty | Increment the value of a room property |
GetNumberOfMembers | Get information about the number of members in the room |
Register | Register a room |
FindRoomByType | Search for a room |
Reserve | Reserve a room |
CancelReservation | Cancel room reservation |
Migrate | Migrate a room |
Move | Move a room |
SendChatMessage | Send a chat message |
GetChatLog | Get the chat log |
StartP2PSync | Get the connection addresses of each client to switch to P2P connection |
Event List (Room)
Event | Type | Corresponding Method | Role |
---|---|---|---|
OnRoomCreate | Response | Create | - |
OnRoomJoin | Response | Join | - |
OnRoomLeave | Response | Leave | - |
OnRoomMemberJoin | Push | - | A member joined |
OnRoomMemberLeave | Push | - | A member left |
OnRoomMemberBroadcast | Push | Broadcast, BroadcastTo | - |
OnRoomMemberMessage | Push | MessageTo | - |
OnRoomUpdateProperties | Response | UpdateProperties | - |
OnRoomGetProperties | Response | GetProperties | - |
OnRoomGetOwnerID | Response | GetOwnerID | - |
OnRoomIncrProperty | Response | IncrProperty | - |
OnRoomIncrPropertySync | Push | IncrProperty | - |
OnRoomGetMemberIDs | Response | GetMemberIDs | - |
OnRoomRegister | Response | Register | - |
OnRoomFindRoomsByType | Response | FindRoomByType | - |
OnRoomReserve | Response | Reserve | - |
OnRoomCancelReservation | Response | CancelReservation | - |
OnRoomGetNumberOfMembers | Response | GetNumberOfMembers | - |
OnRoomChatSyncResponse | Response | SendChatMessage | - |
OnRoomChatSync | Push | SendChatMessage | - |
OnRoomChatLog | Response | GetChatLog | - |
OnRoomStartP2PSync | Push | StartP2PSync | - |
OnRoomObjectSync | Response | SyncObjects | - |
OnRoomObjectUpdate | Push | UpdateObject | - |
OnRoomOwnerChange | Push | - | Owner changed |
Group Features
Namespace | Diarkis.Modules |
Class Name | DiarkisGroup |
Access Method | DiarkisNetworkManger.Instance.Modules.Group |
Interface Representing Events | IDiarkisGroupEvent |
Event Component for Unity | DiarkisGroupEventCallback |
Property List (Group)
Property | Role |
---|---|
GroupIDs | List of IDs of the groups joined |
IsJoined | Whether joined in a group |
Method List (Group)
Method | Role |
---|---|
Create | Create a group |
Join | Join a group |
JoinRandom | Join a group randomly |
Leave | Leave a group |
BroadcastTo | Send data to a group |
Event List (Group)
Event | Type | Corresponding Method | Role |
---|---|---|---|
OnGroupCreate | Response | Create | - |
OnGroupJoin | Response | Join | - |
OnGroupLeave | Response | Leave | - |
OnGroupMemberJoin | Push | - | A member joined |
OnGroupMemberLeave | Push | - | A member left |
OnGroupMemberBroadcast | Push | BroadcastTo | - |
Field Features
Namespace | Diarkis.Modules |
Class Name | DiarkisField |
Access Method | DiarkisNetworkManger.Instance.Modules.Field |
Interface Representing Events | IDiarkisFieldEvent |
Event Component for Unity | DiarkisFieldEventCallback |
Property List (Field)
Property | Role |
---|---|
- | - |
Method List (Field)
Method | Role |
---|---|
SyncInit | Initialize synchronization |
Sync | Send data to sync |
Disappear | Leave the Field |
Event List (Field)
Event | Type | Corresponding Method | Role |
---|---|---|---|
OnFieldResponseSyncInit | Response | SyncInit | - |
OnFieldSync | Push | Sync | - |
OnFieldDisappear | Push | Disappear | Someone disappeared from view |
MatchMaker Features
Namespace | Diarkis.Modules |
Class Name | DiarkisMatchMaker |
Access Method | DiarkisNetworkManger.Instance.Modules.MatchMaker |
Interface Representing Events | IDiarkisMatchMakerEvent |
Event Component for Unity | DiarkisMatchMakerEventCallback |
Property List (MatchMaker)
Property | Role |
---|---|
RoomID | ID of the matched room |
Method List (MatchMaker)
Method | Role |
---|---|
IsTeamMatchmaking | Whether it is team matchmaking |
HostMatchmaking | Host matchmaking |
HostTeamMatchmaking | Host team matchmaking |
ClearMatchmaking | Clear matchmaking |
DisbandMatchmaking | Disband matchmaking |
Kick | Kick a member |
ClaimReservedMatchmaking | Claim a reserved room |
JoinMatchmakingFromResult | Join a matchmaking from result |
LeaveMatchmaking | Leave matchmaking |
Sync | Send data |
NotifyMatchmakingCompletion | Notify completion of matchmaking |
P2PAddressSync | Get address information for P2P |
SetMaxMatchMembers | Set the number of members for matchmaking |
Search | Start matchmaking search |
TeamSearch | Start team matchmaking search |
Commit | Instruct to commit to team matchmaking |
StartBackfill | - |
Event List (MatchMaker)
Event | Type | Corresponding Method | Role |
---|---|---|---|
OnMatchMakerKickResponse | Response | Kick | - |
OnMatchMakerHostMatchmakingResponse | Response | HostMatchmaking | - |
OnMatchMakerHostTeamMatchmakingResponse | Response | HostTeamMatchmaking | - |
OnMatchMakerAbortMatchmakingResponse | Response | ClearMatchmaking | - |
OnMatchMakerDisbandMatchmaking | Push | DisbandMatchmaking | - |
OnMatchMakerMemberLeave | Push | - | A member left |
OnMatchMakerMemberJoin | Push | - | A member joined |
OnMatchMakerMemberSync | Push | Sync | - |
OnMatchMakerJoinResponse | Response | ClaimReservedMatch |
最終更新