Skip to content

Commit d3bc42b

Browse files
authored
Merge pull request #3 from araxiaonline/add-zeromq-event-bus
feat(eventbus): Add ZeroMQ Event Bus with comprehensive game event hooks
2 parents cf2d839 + 50631d4 commit d3bc42b

39 files changed

+6513
-25
lines changed

AGENTS.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,72 @@ handler.ParseCommands(command);
4545
### Key Files with Important Comments:
4646
- `src/araxiaonline/mcp/ServerTools.cpp` - GM command implementation pattern
4747
- `src/araxiaonline/mcp/AraxiaMCPServer.cpp` - MCP server architecture
48+
- `src/araxiaonline/eventbus/AraxiaEvents.h` - Event interface and concrete event classes
49+
50+
---
51+
52+
## Araxia Event Bus
53+
54+
The Event Bus is a ZeroMQ-based real-time event system that publishes game events to external consumers.
55+
56+
- **Documentation**: `/opt/trinitycore/araxia-content-tools/docs/game_engine/araxia_event_bus.md`
57+
- **Source**: `src/araxiaonline/eventbus/`
58+
- **Port**: `tcp://*:5555` (configurable)
59+
60+
### Supported Events
61+
| Category | Events |
62+
|----------|--------|
63+
| Player | login, logout, death |
64+
| Quest | accept, complete, abandon |
65+
| Combat | enter, leave |
66+
| Loot | item |
67+
| Spawn | create, delete |
68+
| Encounter | start, wipe, end |
69+
70+
### Quick Test
71+
```bash
72+
cd /opt/trinitycore/TrinityCore/src/araxiaonline/tools
73+
source .venv/bin/activate
74+
python zmq_subscriber.py
75+
```
76+
77+
**Keep the wiki page updated** when adding new event types or changing the event bus architecture.
78+
79+
---
80+
81+
## AI Testing with Scarletseer
82+
83+
**Scarletseer** is a dedicated test character for AI assistants to use for automated testing via MCP.
84+
85+
- **Character**: Scarletseer (GUID 7, Level 80 Tauren Shaman)
86+
- **Location**: Pandaria (Map 870) - Halfhill Farm area
87+
- **Documentation**: See `/opt/trinitycore/araxia-content-tools/docs/game_engine/scarletseer.md`
88+
89+
### Quick Start
90+
```
91+
mcp_session_create(owner_name="Cascade")
92+
mcp_player_login(session_id=1, character_name="Scarletseer")
93+
mcp_player_status(session_id=1) # Verify login
94+
# ... run tests ...
95+
mcp_player_logout(session_id=1)
96+
```
97+
98+
### Event Bus Testing
99+
Scarletseer can trigger events for the ZeroMQ event bus:
100+
- **Player events**: login, logout, death
101+
- **Quest events**: accept, complete, abandon
102+
- **Combat events**: enter, leave
103+
- **Loot events**: item looted
104+
- **Encounter events**: start, wipe, end (requires dungeon/raid)
105+
106+
Monitor events with: `python /opt/trinitycore/TrinityCore/src/araxiaonline/tools/zmq_subscriber.py`
107+
108+
---
109+
110+
### Building the server
111+
- Always use the max number of threads when building the server
112+
- Always use @araxiaonline/cmake_setup.sh to setup the build environment. Modify it if needed.
113+
- Please fix all compile warnings before marking a task as complete.
114+
115+
### Pushing changes
116+
- Our working branch is `araxia-main` and all branches and PRs should be based on this branch.

araxiaonline/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
DB_HOST=host.docker.internal
1010
DB_PORT=3306
1111
DB_USER=trinity
12-
DB_PASSWORD=trinity
12+
DB_PASSWORD=<YOUR_SECURE_PASSWORD_HERE>
1313
DB_AUTH=auth
1414
DB_CHARACTERS=characters
1515
DB_WORLD=world

araxiaonline/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ ENV LC_ALL=en_US.UTF-8
6060
RUN update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100 && \
6161
update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100
6262

63-
# Create trinitycore user with sudo privileges
63+
# Create trinitycore user with sudo privileges (requires password)
6464
RUN useradd -m -s /bin/bash -G sudo trinitycore && \
65-
echo "trinitycore ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
65+
echo "trinitycore ALL=(ALL) ALL" >> /etc/sudoers
6666

6767
# Create necessary directories
6868
RUN mkdir -p \

araxiaonline/ams/AMS_Client/AMS_Client.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ local function SendAddonMessage(message)
119119
if #message <= AMS_MAX_MSG_LENGTH then
120120
-- Prefix with marker for short message (ID = 0000, parts = 0000, partID = 0000)
121121
local packet = NumberToHex(0) .. NumberToHex(0) .. NumberToHex(0) .. message
122-
-- Use PARTY channel for solo players, fallback to WHISPER if in party
122+
-- Use WHISPER channel for solo players, PARTY if in a group
123123
local channel = IsInGroup() and "PARTY" or "WHISPER"
124124
local target = channel == "WHISPER" and UnitName("player") or nil
125125
Debug("Sending via channel:", channel, "target:", target or "none", "prefix:", AMS_PREFIX)
@@ -134,7 +134,7 @@ local function SendAddonMessage(message)
134134

135135
Debug("Splitting message ID", msgID, "into", totalParts, "parts")
136136

137-
-- Use PARTY channel for solo players, fallback to WHISPER if in party
137+
-- Use WHISPER channel for solo players, PARTY if in a group
138138
local channel = IsInGroup() and "PARTY" or "WHISPER"
139139
local target = channel == "WHISPER" and UnitName("player") or nil
140140

araxiaonline/ams/AMS_Server.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ local AMS_MSG_MAX_ID = 65535 -- 16-bit ID
4242
-- Dependencies
4343
-- ============================================================================
4444

45-
-- Smallfolk for serialization (already in AIO deps)
46-
local Smallfolk = require("AIO_Server.Dep_Smallfolk.smallfolk")
45+
-- Smallfolk for serialization (vendored in AMS_Server directory)
46+
local Smallfolk = require("AMS_Server.smallfolk")
47+
48+
-- Chat channel constants for clarity
49+
local CHAT_CHANNEL_WHISPER = 7 -- CHAT_MSG_WHISPER
4750

4851
-- ============================================================================
4952
-- Core AMS Table
@@ -120,7 +123,7 @@ local function SendAddonMessage(player, message)
120123
if #message <= AMS_MAX_MSG_LENGTH then
121124
-- Prefix with marker for short message (ID = 0000, parts = 0000, partID = 0000)
122125
local packet = NumberToHex(0) .. NumberToHex(0) .. NumberToHex(0) .. message
123-
player:SendAddonMessage(AMS_PREFIX, packet, 7, player)
126+
player:SendAddonMessage(AMS_PREFIX, packet, CHAT_CHANNEL_WHISPER, player)
124127
return
125128
end
126129

@@ -142,7 +145,7 @@ local function SendAddonMessage(player, message)
142145
NumberToHex(partID)
143146

144147
local packet = header .. chunk
145-
player:SendAddonMessage(AMS_PREFIX, packet, 7, player)
148+
player:SendAddonMessage(AMS_PREFIX, packet, CHAT_CHANNEL_WHISPER, player)
146149
end
147150
end
148151

araxiaonline/araxia_docs/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@ RUN apt-get update && apt-get install -y \
7474
libbz2-1.0 \
7575
libreadline8t64 \
7676
libncurses6 \
77-
libboost-all-dev \
77+
libboost-system1.83.0 \
78+
libboost-filesystem1.83.0 \
79+
libboost-thread1.83.0 \
80+
libboost-program-options1.83.0 \
81+
libboost-iostreams1.83.0 \
82+
libboost-regex1.83.0 \
83+
libboost-locale1.83.0 \
7884
ca-certificates \
7985
&& rm -rf /var/lib/apt/lists/*
8086

araxiaonline/araxia_docs/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ services:
66
image: mysql:8.0
77
container_name: trinitycore-mysql
88
environment:
9-
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-trinity}
9+
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:?Please set MYSQL_ROOT_PASSWORD in .env}
1010
MYSQL_DATABASE: ${MYSQL_AUTH_DATABASE:-auth}
1111
MYSQL_USER: ${MYSQL_USER:-trinity}
12-
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-trinity}
12+
MYSQL_PASSWORD: ${MYSQL_PASSWORD:?Please set MYSQL_PASSWORD in .env}
1313
volumes:
1414
- mysql-data:/var/lib/mysql
1515
- ./sql:/docker-entrypoint-initdb.d:ro
@@ -19,7 +19,7 @@ services:
1919
- trinitycore
2020
command: --default-authentication-plugin=mysql_native_password --max_allowed_packet=512M
2121
healthcheck:
22-
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD:-trinity}"]
22+
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD}"]
2323
interval: 10s
2424
timeout: 5s
2525
retries: 5

araxiaonline/client_addons/AMS_Client/AMS_Client.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ local function SendAddonMessage(message)
119119
if #message <= AMS_MAX_MSG_LENGTH then
120120
-- Prefix with marker for short message (ID = 0000, parts = 0000, partID = 0000)
121121
local packet = NumberToHex(0) .. NumberToHex(0) .. NumberToHex(0) .. message
122-
-- Use PARTY channel for solo players, fallback to WHISPER if in party
122+
-- Use WHISPER channel for solo players, PARTY if in a group
123123
local channel = IsInGroup() and "PARTY" or "WHISPER"
124124
local target = channel == "WHISPER" and UnitName("player") or nil
125125
Debug("Sending via channel:", channel, "target:", target or "none", "prefix:", AMS_PREFIX)
@@ -134,7 +134,7 @@ local function SendAddonMessage(message)
134134

135135
Debug("Splitting message ID", msgID, "into", totalParts, "parts")
136136

137-
-- Use PARTY channel for solo players, fallback to WHISPER if in party
137+
-- Use WHISPER channel for solo players, PARTY if in a group
138138
local channel = IsInGroup() and "PARTY" or "WHISPER"
139139
local target = channel == "WHISPER" and UnitName("player") or nil
140140

araxiaonline/lua_scripts/AMS_Server/AMS_Server.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ local AMS_MSG_MAX_ID = 65535 -- 16-bit ID
4242
-- Dependencies
4343
-- ============================================================================
4444

45-
-- Smallfolk for serialization
45+
-- Smallfolk for serialization (vendored in AMS_Server directory)
4646
local Smallfolk = require("AMS_Server.smallfolk")
4747

48+
-- Chat channel constants for clarity
49+
local CHAT_CHANNEL_WHISPER = 7 -- CHAT_MSG_WHISPER
50+
4851
-- ============================================================================
4952
-- Core AMS Table
5053
-- ============================================================================
@@ -124,7 +127,7 @@ local function SendAddonMessage(player, message)
124127
if #message <= AMS_MAX_MSG_LENGTH then
125128
-- Prefix with marker for short message (ID = 0000, parts = 0000, partID = 0000)
126129
local packet = NumberToHex(0) .. NumberToHex(0) .. NumberToHex(0) .. message
127-
player:SendAddonMessage(AMS_PREFIX, packet, 7, player)
130+
player:SendAddonMessage(AMS_PREFIX, packet, CHAT_CHANNEL_WHISPER, player)
128131
return
129132
end
130133

@@ -146,7 +149,7 @@ local function SendAddonMessage(player, message)
146149
NumberToHex(partID)
147150

148151
local packet = header .. chunk
149-
player:SendAddonMessage(AMS_PREFIX, packet, 7, player)
152+
player:SendAddonMessage(AMS_PREFIX, packet, CHAT_CHANNEL_WHISPER, player)
150153
end
151154
end
152155

dep/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ if(SERVERS)
3333
add_subdirectory(rapidjson)
3434
add_subdirectory(efsw)
3535
add_subdirectory(protobuf)
36+
add_subdirectory(zeromq)
3637
endif()
3738

3839
if(TOOLS)

0 commit comments

Comments
 (0)