Skip to content

ワールドインスタンス

ワールドインスタンスは、ワールドマニフェストから作られる実行中のライブセッションです。

ワールドは安定したコンテンツと権限を表します。インスタンスは、そのワールドの「今動いている部屋」を表し、割り当てられた ID、接続先、定員、現在の状態を持ちます。

インスタンス object

各インスタンスには、WorldServer が割り当てる id があります。

json
{
  "id": "inst_01HZY8K7N2Q4Y6Z8A0B1C2D3E4",
  "worldId": "medi:world:ed25519:base64url-world-public-key",
  "endpoint": "https://worlds.example.com/",
  "name": "Main",
  "state": "open",
  "playerCount": 12,
  "capacity": 32,
  "joinPolicy": "public",
  "createdAt": 1770000000,
  "updated_at": 1770000100,
  "worldProtocols": [
    {
      "name": "me.virmesh.world.websocket",
      "version": "1.0.0",
      "information": {
        "uri": "wss://worlds.example.com/instances/inst_01HZY8K7N2Q4Y6Z8A0B1C2D3E4/session"
      }
    }
  ]
}

インスタンスの id は不透明な文字列です。クライアントは、この値から world、server、作成時刻などの情報を読み取ろうとしてはいけません。

Action 一覧

me.virmesh.worldInstance 名前空間には、3 つの action があります。

Action目的
me.virmesh.worldInstance.listInstance現在の WorldServer 上にある、指定 world の instance 一覧を取得します。
me.virmesh.worldInstance.getInstanceinstance id から 1 つの instance を取得します。
me.virmesh.worldInstance.createInstanceサーバーが対応している場合に、新しい instance を作成します。

listInstancegetInstance は public action です。createInstance はサーバー上に状態を作るため private action とし、サーバー側のポリシーで制限できます。

Instance 作成は任意

WorldServer は、me.virmesh.worldInstance.createInstance をサポートするかどうかを選択できます。

たとえば、1 つの world につき常に 1 つの instance だけを提供するサーバーでは、動的な instance 作成をサポートしない設計にできます。その場合、createInstance には status+me.virmesh.action.not_supported を返します。クライアントは listInstance または getInstance で既存 instance を見つけ、返された worldProtocols を使って参加します。

複数 room、イベント用 session、player が作る一時 room を提供するサーバーは、createInstance を有効にして独自のアクセスポリシーを適用できます。

サーバーは world+me.virmesh.world.instancePolicy module で、createInstance の対応可否や既定 capacity を事前に公開できます。ただし、最終的な作成可否は me.virmesh.worldInstance.createInstance 実行時のサーバーポリシーで判断します。

クライアントの流れ

基本の流れは次の通りです。

  1. world address(例: example.com/world)、catalog entry、または既知の worldIdme.virmesh.world.resolveWorld で world manifest に解決し、署名を検証します。
  2. 検証済みの worldId を使って me.virmesh.worldInstance.listInstance を呼び出します。
  3. レスポンス内の instance を選びます。
  4. 参加直前に必要であれば me.virmesh.worldInstance.getInstance を呼び、状態を更新します。
  5. 返された worldProtocols のいずれかに接続します。

適切な instance が存在しない場合、クライアントはサーバーがその action を公開している、または受理する場合に限って createInstance を呼び出せます。

次に読む