Creating Moorestech Server Protocols

VerifiedSafe

This guide helps create server protocols for moorestech, covering both request-response and event-driven types. It provides step-by-step instructions for creating protocol classes, registering them in PacketResponseCreator, and writing tests. Use when implementing new packet responses or event packets for client-server communication.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude Code
#server-protocol#packet-response#event-packet#messagepack#unity

Recommended for

Automated summary

Creates server request-response and event packet protocols for the moorestech server using MessagePack serialization.

Strengths

  • Clear step-by-step instructions for creating server protocols
  • Covers both request-response and event-based protocols
  • Includes protocol registration and testing references
  • Uses dependency injection and standard design patterns

Limitations

  • Specific to the moorestech server codebase (Unity/MessagePack)
  • Requires understanding of existing architecture
  • Does not cover generic protocols or other frameworks
When to use it

When adding new client-server communication in the moorestech server.

When not to use it

For generic network protocol design outside the moorestech ecosystem.

Security analysis

Safe
Quality score90/100

This skill only provides guidance for implementing server protocols in C# within a Unity game project. There are no executable commands, network calls, or destructive actions described. It is purely instructional.

No concerns found

How this analysis is made

Examples

Request-Response for Player Inventory
Create a new request-response protocol for getting a player's inventory. The client should send a player ID and receive a list of items with quantities.
Event Packet for Player Death
Add an event packet that notifies all clients when a player dies, including the player ID and death position.
Protocol for Chat Messages
Implement a request-response protocol to send a chat message from client to server, and an event to broadcast chat messages to all players.

name: creating-server-protocol description: | moorestechサーバーのプロトコル(Request-Response型・Event型)を作成するためのガイド。 Use when:

  1. 新しいサーバープロトコル(IPacketResponse)を実装する時
  2. 新しいイベントパケット(EventPacket)を実装する時
  3. 「プロトコルを作って」「パケットを追加して」と依頼された時
  4. クライアント-サーバー間の通信を新規追加する時

サーバープロトコル作成ガイド

プロトコル選択

| 条件 | 種類 | |------|------| | クライアントが明示的に情報を要求/操作を実行 | Request-Response型 | | サーバー側の状態変化をクライアントに通知 | Event型 |

詳細パターンとコード例: references/protocol-patterns.md を参照。

Request-Response型の作成手順

Step 1: プロトコルクラスを作成

moorestech_server/Assets/Scripts/Server.Protocol/PacketResponse/ に新規ファイルを作成。

using System;
using System.Collections.Generic;
using MessagePack;
using Server.Protocol;

namespace Server.Protocol.PacketResponse
{
    public class YourProtocol : IPacketResponse
    {
        public const string ProtocolTag = "va:yourProtocol";

        private readonly ISomeDependency _dependency;

        public YourProtocol(ServiceProvider serviceProvider)
        {
            _dependency = serviceProvider.GetService<ISomeDependency>();
        }

        public ProtocolMessagePackBase GetResponse(byte[] payload)
        {
            var data = MessagePackSerializer.Deserialize<YourRequestMessagePack>(payload);
            // ビジネスロジック
            return new YourResponseMessagePack(/* result */);
        }

        #region MessagePack

        [MessagePackObject]
        public class YourRequestMessagePack : ProtocolMessagePackBase
        {
            // Key(0)=Tag, Key(1)=SequenceId は基底クラスで予約済み
            [Key(2)] public int SomeField { get; set; }

            [Obsolete("デシリアライズ用のコンストラクタです。基本的に使用しないでください。")]
            public YourRequestMessagePack() { }

            public YourRequestMessagePack(int someField)
            {
                Tag = ProtocolTag;
                SomeField = someField;
            }
        }

        [MessagePackObject]
        public class YourResponseMessagePack : ProtocolMessagePackBase
        {
            [Key(2)] public string ResultData { get; set; }

            [Obsolete("デシリアライズ用のコンストラクタです。基本的に使用しないでください。")]
            public YourResponseMessagePack() { }

            public YourResponseMessagePack(string resultData)
            {
                Tag = ProtocolTag;
                ResultData = resultData;
            }
        }

        #endregion
    }
}

Step 2: PacketResponseCreatorに登録

moorestech_server/Assets/Scripts/Server.Protocol/PacketResponseCreator.cs のコンストラクタに追加:

_packetResponseDictionary.Add(YourProtocol.ProtocolTag, new YourProtocol(serviceProvider));

Step 3: テストを作成

/creating-server-tests スキルを使用してテストを作成。配置先: Tests/CombinedTest/Server/PacketTest/

Step 4: コンパイル確認

MCPツールまたはunity-test.shでコンパイルを確認。


Event型の作成手順

Step 1: イベントパケットクラスを作成

moorestech_server/Assets/Scripts/Server.Event/EventReceive/ に新規ファイルを作成。

using System;
using Game.Context;
using MessagePack;
using Server.Event;

namespace Server.Event.EventReceive
{
    public class YourEventPacket
    {
        public const string EventTag = "va:event:yourEvent";
        private readonly EventProtocolProvider _eventProtocolProvider;

        public YourEventPacket(EventProtocolProvider eventProtocolProvider)
        {
            _eventProtocolProvider = eventProtocolProvider;
            // ゲームイベントを購読(UniRx .Subscribe)
            ServerContext.SomeEvent.OnSomething.Subscribe(OnSomething);
        }

        private void OnSomething(SomeEventData eventData)
        {
            var messagePack = new YourEventMessagePack(eventData.Value);
            var payload = MessagePackSerializer.Serialize(messagePack);

            // 全プレイヤー: AddBroadcastEvent / 特定プレイヤー: AddEvent(playerId, ...)
            _eventProtocolProvider.AddBroadcastEvent(EventTag, payload);
        }

        #region MessagePack

        [MessagePackObject]
        public class YourEventMessagePack
        {
            // EventのMessagePackはProtocolMessagePackBaseを継承しない。Key(0)から開始
            [Key(0)] public string Value { get; set; }

            [Obsolete("デシリアライズ用のコンストラクタです。基本的に使用しないでください。")]
            public YourEventMessagePack() { }

            public YourEventMessagePack(string value)
            {
                Value = value;
            }
        }

        #endregion
    }
}

Step 2: イベントパケットを初期化

イベントを発火する責任を持つシステムのコンストラクタでインスタンス化し、フィールドに保持する(GC防止)。

例: ブロック配置イベント → BlockUpdateSystemで初期化、レールノード作成イベント → RailGraphDatastore関連で初期化。

Step 3: テストを作成

/creating-server-tests スキルを使用。配置先: Tests/CombinedTest/Server/PacketTest/Event/

Step 4: コンパイル確認

MCPツールまたはunity-test.shでコンパイルを確認。


注意事項

  • タグの一意性を必ず確認する(既存タグと重複しないこと)
  • MessagePackのKey番号: Request/ResponseはKey(2)から、EventデータはKey(0)から
  • [Obsolete]付き引数なしコンストラクタは省略不可
  • イベント購読はUniRxの.Subscribe()を使用(/csharp-event-pattern参照)
  • コードのコメントは日本語・英語の2行セット

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/creating-moorestech-server-protocols-mma3jqyp/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/creating-moorestech-server-protocols-mma3jqyp' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/creating-moorestech-server-protocols-mma3jqyp/download' --output '.skill-downloads/creating-moorestech-server-protocols-mma3jqyp/SKILL.md.part' && mv '.skill-downloads/creating-moorestech-server-protocols-mma3jqyp/SKILL.md.part' '.skill-downloads/creating-moorestech-server-protocols-mma3jqyp/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/creating-moorestech-server-protocols-mma3jqyp/SKILL.md' && test -s '.skill-downloads/creating-moorestech-server-protocols-mma3jqyp/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/creating-server-protocol' && cp -R '.skill-downloads/creating-moorestech-server-protocols-mma3jqyp' '.claude/skills/creating-server-protocol'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/creating-moorestech-server-protocols-mma3jqyp'

openskills read 'creating-moorestech-server-protocols-mma3jqyp'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/creating-moorestech-server-protocols-mma3jqyp/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills