HowToUsePlugin.md
Table of Contents
Installation Instructions
1. Import Unity Package
Import the DiarkisUnityPlugin.unitypackage
into the target project.
2. Configure Connection Information
Select Assets/Diarkis/Prefabs/DiarkisNetworkManager
, and display the DiarkisNetworkManager
script in the Inspector.
Then, click on the item labeled Transport
to show its contents and configure the connection information with Diarkis as follows:
HttpHost
EndPoint URL
asia-northeast1.diarkis.io/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
ClientKey
Client Key Value
XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX (It's OK to leave blank)
3. Place the Prefab in the Scene
Place the configured DiarkisNetworkManager
prefab into the scene.
Verify that AutoStartConnect
is checked (it's on by default), and click the play button at the top of the editor.
This will automatically start the connection to the Diarkis server.
How to Use the Plugin
How to Configure DiarkisNetworkManager Prefab
DiarkisNetworkManager
is a crucial class for connecting with Diarkis and must be placed in the scene.
Important configuration items include:
Transport.HttpHost
EndPoint URL value
Transport.ClientKey
Client Key value
Transport.AutoRetryTimes
Number of retries if the connection to Diarkis server fails
AutoStartConnect
Whether to start connection to Diarkis server automatically
IsWaitDisconnectOnAppQuit
Whether to wait for disconnection processing with Diarkis server to complete when quitting the app
WaitDisconnectTime
Maximum time to wait for the above process. If this time expires, the app will forcefully close
Request to Connect & Disconnect from the Network
To connect (or disconnect) to the Diarkis network, call functions via DiarkisNetworkManager
.
Receive Responses for Network Connect & Disconnect
You can receive responses from the server as events.
First, add a component to the scene to trigger events.
Add an appropriate GameObject
to the scene and attach the DiarkisCoreEventCallback
component to it.
You can register functions with this component, which will trigger in response to events.
Create a class to register functions as follows:
Attach this script to an appropriate GameObject
, and register the desired function to be called during an event in DiarkisCoreEventCallback
.
Thus, you can receive responses from the server.
Use Various Modules
Diarkis contains the following modules:
Room
Assets\Diarkis\Runtime\Extension\MonoBehaviour\Callbacks\Modules\DiarkisRoomEventCallback.cs
Group
Assets\Diarkis\Runtime\Extension\MonoBehaviour\Callbacks\Modules\DiarkisGroupEventCallback.cs
Field
Assets\Diarkis\Runtime\Extension\MonoBehaviour\Callbacks\Modules\DiarkisFieldEventCallback.cs
MatchMaker
Assets\Diarkis\Runtime\Extension\MonoBehaviour\Callbacks\Modules\DiarkisMatchMakerEventCallback.cs
P2P
Assets\Diarkis\Runtime\Extension\MonoBehaviour\Callbacks\Modules\DiarkisP2PEventCallback.cs
To send data, call the corresponding functions of various modules.
To receive data, place a corresponding event component in the scene and register functions with it.
Here is an example of how to create a new room using the Room
module.
Send Requests via Room Module
The following code creates a new room using the Room
module.
Receive Responses from Room Module
First, attach DiarkisRoomEventCallback
to an appropriate GameObject
in the scene.
Next, create a class to receive events as follows:
Finally, place this script in the scene and register the function in OnRoomCreate
of DiarkisRoomEventCallback
.
This way, you can receive the result when calling Room.Create
.
Here, the Room
module was taken as an example, but the usage is similar for other modules.
Reference for Each Feature
Core Features
Namespace
Diarkis
Class Name
DiarkisNetworkManager
Access Method
DiarkisNetworkManager.Instance
Interface for Events
IDiarkisCoreEvent
Unity Event Component
DiarkisCoreEventCallback
List of Properties (Core)
UID
Unique identifier for this client.
Modules
Various modules (Room, Group, Field...).
List of Methods (Core)
IsConnected
Whether it's connected to the network.
Connect
Connect to the network.
Disconnect
Disconnect from the network.
List of Events (Core)
OnNetworkConnect
Connected to the network.
OnNetworkDisconnect
Disconnected from the network.
OnNetworkException
An exception occurred during communication.
OnNetworkOffline
Ready to shut down the server.
OnApplicationWantsToQuit
The application is attempting to quit.
Features Related to Room
Namespace
Diarkis.Modules
Class Name
DiarkisRoom
Access Method
DiarkisNetworkManager.Instance.Modules.Room
Interface for Events
IDiarkisRoomEvent
Unity Event Component
DiarkisRoomEventCallback
List of Properties (Room)
IsJoined
Whether you're joined in a room.
RoomID
The ID of the room.
OwnerUID
The UID of the room owner.
MemberUIDs
The UIDs of room members (including self & owner).
List of Methods (Room)
Create
Create a room.
Join
Join a room.
JoinRandom
Join a random room.
Leave
Leave a room.
GetOwnerID
Get the room owner's ID.
GetMemberIDs
Get room members' IDs.
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 room properties.
GetProperties
Get room properties.
IncrProperty
Increment the value of a room property.
GetNumberOfMembers
Get information about the number of room members.
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 a chat log.
StartP2PSync
Get client connection addresses for P2P switch.
List of Events (Room)
OnRoomCreate
Response
Create
-
OnRoomJoin
Response
Join
-
OnRoomLeave
Response
Leave
-
OnRoomMemberJoin
Push
-
Member joined
OnRoomMemberLeave
Push
-
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
Features Related to Group
Namespace
Diarkis.Modules
Class Name
DiarkisGroup
Access Method
DiarkisNetworkManager.Instance.Modules.Group
Interface for Events
IDiarkisGroupEvent
Unity Event Component
DiarkisGroupEventCallback
List of Properties (Group)
GroupIDs
List of IDs for groups you're in.
IsJoined
Whether you're a member of a group.
List of Methods (Group)
Create
Create a group.
Join
Join a group.
JoinRandom
Randomly join a group.
Leave
Leave a group.
BroadcastTo
Send data to a group.
List of Events (Group)
OnGroupCreate
Response
Create
-
OnGroupJoin
Response
Join
-
OnGroupLeave
Response
Leave
-
OnGroupMemberJoin
Push
-
Member joined
OnGroupMemberLeave
Push
-
Member left
OnGroupMemberBroadcast
Push
BroadcastTo
-
Features Related to Field
Namespace
Diarkis.Modules
Class Name
DiarkisField
Access Method
DiarkisNetworkManager.Instance.Modules.Field
Interface for Events
IDiarkisFieldEvent
Unity Event Component
DiarkisFieldEventCallback
List of Properties (Field)
-
-
List of Methods (Field)
SyncInit
Initialize sync process.
Sync
Send data to sync.
Disappear
Leave the Field.
List of Events (Field)
OnFieldResponseSyncInit
Response
SyncInit
-
OnFieldSync
Push
Sync
-
OnFieldDisappear
Push
Disappear
Someone disappeared from view
Features Related to MatchMaker
Namespace
Diarkis.Modules
Class Name
DiarkisMatchMaker
Access Method
DiarkisNetworkManager.Instance.Modules.MatchMaker
Interface for Events
IDiarkisMatchMakerEvent
Unity Event Component
DiarkisMatchMakerEventCallback
List of Properties (MatchMaker)
RoomID
ID of the matched room
List of Methods (MatchMaker)
IsTeamMatchmaking
Whether it's team matchmaking.
HostMatchmaking
Host matchmaking.
HostTeamMatchmaking
Host team matchmaking.
ClearMatchmaking
Clear matchmaking.
DisbandMatchmaking
Disband matchmaking.
Kick
Kick a member.
ClaimReservedMatchmaking
Obtain reserved room.
JoinMatchmakingFromResult
Participate in matchmaking.
LeaveMatchmaking
Leave matchmaking.
Sync
Send data.
NotifyMatchmakingCompletion
Notify matchmaking completion.
P2PAddressSync
Retrieve address information related to P2P.
SetMaxMatchMembers
Set number of members for matchmaking.
Search
Start matchmaking search.
TeamSearch
Start team matchmaking search.
Commit
Instruct to perform team matchmaking.
StartBackfill
-
List of Events (MatchMaker)
OnMatchMakerKickResponse
Response
Kick
-
OnMatchMakerHostMatchmakingResponse
Response
HostMatchmaking
-
OnMatchMakerHostTeamMatchmakingResponse
Response
HostTeamMatchmaking
-
OnMatchMakerAbortMatchmakingResponse
Response
ClearMatchmaking
-
OnMatchMakerDisbandMatchmaking
Push
DisbandMatchmaking
-
OnMatchMakerMemberLeave
Push
-
Member left
OnMatchMakerMemberJoin
Push
-
Member joined
OnMatchMakerMemberSync
Push
Sync
-
OnMatchMakerJoinResponse
Response
ClaimReservedMatchmaking
-
OnMatchMakerLeaveResponse
Response
LeaveMatchmaking
-
OnMatchMakerComplete
Push
-
Filled slots
OnMatchMakerKick
Push
Kick
-
OnMatchMakerSearchResponse
Response
Search
-
OnMatchMakerTeamSearchResponse
Response
TeamSearch
-
OnMatchMakerResultsResponse
Response
Search
-
OnMatchMakerTeamResultsResponse
Response
TeamSearch
-
OnMatchMakerP2PAddressSync
Push
P2PAddressSync
-
OnMatchMakerP2PAddressSyncResponse
Response
P2PAddressSync
-
OnMatchMakerBackfillStartResponse
Response
StartBackfill
-
OnMatchMakerCommitResponse
Response
Commit
-
OnMatchMakerCompleteCommit
Response
Commit
-
OnMatchMakerTicketComplete
Push
-
-
OnMatchMakerHostChange
Push
-
Host changed
OnMatchMakerCancelTicket
Response
-
-
Features Related to P2P
Namespace
Diarkis.Modules
Class Name
DiarkisP2P
Access Method
DiarkisNetworkManager.Instance.Modules.P2P
Interface for Events
IDiarkisP2PEvent
Unity Event Component
DiarkisP2PEventCallback
List of Properties (P2P)
-
-
List of Methods (P2P)
IsConnected
Whether it's connected.
Connect
Connect.
Disconnect
Disconnect.
Send
Send data.
List of Events (P2P)
OnP2PReady
-
OnP2PFail
-
OnP2PMessage
-
OnP2PException
-
Last updated