Skip to main content

BaseTypeHub

WebSocket hub for base type registry operations. Read operations are available to all authenticated users; write operations require Admin role.

Endpoint: /baseTypeHub

Authorization: All methods require authentication. CRUD operations require Admin role.

Methods

Subscriptions

JoinBaseTypesGroup

Join the base-types group to receive real-time updates.

public async Task JoinBaseTypesGroup()

LeaveBaseTypesGroup

Leave the base-types group.

public async Task LeaveBaseTypesGroup()

Read Operations

GetAll

Get all registered base types.

public async Task<IReadOnlyList<BaseType>> GetAll()

Returns: BaseType[]

{
baseTypeId: string;
name: string;
category: ItemCategory;
slot?: EquipmentSlot;
width: number;
height: number;
implicitModifiers: string[];
requirements: Requirements;
tags: string[];
}

Get

Get a specific base type by ID.

public async Task<BaseType?> Get(string baseTypeId)

GetByCategory

Get base types by category.

public async Task<IReadOnlyList<BaseType>> GetByCategory(ItemCategory category)

ItemCategory Enum:

enum ItemCategory {
Weapon = 0,
Armour = 1,
Accessory = 2,
Gem = 3,
Currency = 4,
Map = 5,
Misc = 6
}

GetBySlot

Get base types by equipment slot.

public async Task<IReadOnlyList<BaseType>> GetBySlot(EquipmentSlot slot)

Exists

Check if a base type exists.

public async Task<bool> Exists(string baseTypeId)

Admin Operations

Create

Create a new base type. Broadcasts to all subscribed clients.

[Authorize(Roles = "Admin")]
public async Task<BaseType> Create(BaseType baseType)

Errors:

  • "Base type '{id}' already exists." - Duplicate ID

Update

Update an existing base type. Broadcasts to all subscribed clients.

[Authorize(Roles = "Admin")]
public async Task<BaseType> Update(string baseTypeId, BaseType baseType)

Errors:

  • "BaseTypeId in request must match." - ID mismatch
  • "Base type '{id}' not found." - Does not exist

Delete

Delete a base type. Broadcasts to all subscribed clients.

[Authorize(Roles = "Admin")]
public async Task Delete(string baseTypeId)

Errors:

  • "Base type '{id}' not found." - Does not exist

Real-Time Events

Subscribe to base type changes:

connection.on("BaseTypeCreated", (baseType) => {
console.log(`New base type: ${baseType.name}`);
// Add to local cache
});

connection.on("BaseTypeUpdated", (baseType) => {
console.log(`Updated: ${baseType.name}`);
// Update local cache
});

connection.on("BaseTypeDeleted", (baseTypeId) => {
console.log(`Deleted: ${baseTypeId}`);
// Remove from local cache
});

await connection.invoke("JoinBaseTypesGroup");

Example Usage

// Get all weapons
const weapons = await connection.invoke("GetByCategory", 0);

// Create a new base type (admin only)
const newType = {
baseTypeId: "iron-sword",
name: "Iron Sword",
category: 0, // Weapon
slot: 4, // MainHand
width: 1,
height: 3,
implicitModifiers: [],
requirements: { level: 1, strength: 10 },
tags: ["sword", "melee", "one-handed"]
};
await connection.invoke("Create", newType);

Registry Architecture