PHPackages                             dayvsonspacca/aqw-socket-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. dayvsonspacca/aqw-socket-client

ActiveLibrary

dayvsonspacca/aqw-socket-client
===============================

v6.0.1(2mo ago)4380↓33.3%MITPHPCI passing

Since Feb 24Pushed 2mo agoCompare

[ Source](https://github.com/dayvsonspacca/aqw-socket-client)[ Packagist](https://packagist.org/packages/dayvsonspacca/aqw-socket-client)[ RSS](/packages/dayvsonspacca-aqw-socket-client/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (15)Used By (0)

AQW Socket Client
=================

[](#aqw-socket-client)

[![Latest Stable Version](https://camo.githubusercontent.com/75ddf909728681c3fa5865a5ca3305ad410b3a84c6f834c3fe8fba59c6e6d977/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64617976736f6e7370616363612f6171772d736f636b65742d636c69656e742e737667)](https://packagist.org/packages/dayvsonspacca/aqw-socket-client)[![Total Downloads](https://camo.githubusercontent.com/f3adddb45d3feedbaf0f22aac35ad206e6944249bf5c22a8757d1431c81d9f12/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64617976736f6e7370616363612f6171772d736f636b65742d636c69656e742e737667)](https://packagist.org/packages/dayvsonspacca/aqw-socket-client)[![License](https://camo.githubusercontent.com/d35278e75a42d56e7b6d8fe137b9d9a97c3cbd7435bc4c982a021ef572388909/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f64617976736f6e7370616363612f6171772d736f636b65742d636c69656e742e737667)](https://packagist.org/packages/dayvsonspacca/aqw-socket-client)

PHP client for connecting and interacting with **Adventure Quest Worlds (AQW)** servers.

Allows login, sending commands, and processing server events in a modular, script-driven way.

> **Note:** This client is not intended to serve as a bot. Its purpose is solely to explore the exchange of information with the AQW server and to retrieve data such as item names and player information.

> **Note:** This project would not have been possible without the following repositories — thank you! [anthony-hyo/swf2png](https://github.com/anthony-hyo/swf2png) · [dwiki08/loving](https://github.com/dwiki08/loving) · [Froztt13/aqw-python](https://github.com/Froztt13/aqw-python) · [BrenoHenrike/RBot](https://github.com/BrenoHenrike/RBot) · [133spider/AQLite](https://github.com/133spider/AQLite)

---

How it works
------------

[](#how-it-works)

The library is built around a simple, linear pipeline. Raw bytes come in from the socket, get parsed into typed messages, get interpreted as high-level events, and finally get handled by a **Script** — which decides what command to send back.

 ```
flowchart LR
    A([AQW Server]) -->|raw bytes| B[Socket]
    B -->|string| C[Message\nXML · JSON · Delimited]
    C -->|typed message| D[Event]
    D -->|dispatched to| E[Script]
    E -->|returns| F[Command]
    F -->|packed as Packet| A
```

      Loading You write a **Script** that declares which events it cares about and reacts to them by returning a command. The client calls `start()` once before the loop begins, then receives messages, resolves events, and dispatches them until the script signals it's done.

Each script call returns **at most one command**, which is enqueued and sent on the next tick. A shared `ClientContext` flows through every call, letting scripts pass data between steps.

 ```
sequenceDiagram
    participant Server as AQW Server
    participant Client
    participant Script

    Client->>Script: start(context)
    Script-->>Client: null

    Client->>Server: connect()
    Server-->>Client: cross-domain-policy (XML)
    Client->>Script: handle(ConnectionEstablishedEvent, context)
    Script-->>Client: LoginCommand
    Client->>Server: send LoginCommand

    Server-->>Client: login response (delimited)
    Client->>Script: handle(LoginRespondedEvent, context)
    Note over Script: stores socket_id in context
    Script-->>Client: null → advances to JoinBattleonScript
    Client->>Script: start(context) [JoinBattleonScript]
    Script-->>Client: JoinInitialAreaCommand
    Client->>Server: send JoinInitialAreaCommand

    Server-->>Client: area joined (JSON)
    Client->>Script: handle(AreaJoinedEvent, context)
    Note over Script: stores area_id in context → advances to LoadInventoryScript
    Client->>Script: start(context) [LoadInventoryScript]
    Script-->>Client: LoadPlayerInventoryCommand
    Client->>Server: send LoadPlayerInventoryCommand

    Server-->>Client: inventory loaded (JSON)
    Client->>Script: handle(PlayerInventoryLoadedEvent, context)
    Note over Script: success() — sequence complete
```

      Loading After `run()` completes, you can read the accumulated state via `context()`:

```
$client->run(new LoginScript($playerName, $token));

$ctx      = $client->context();
$socketId = $ctx->get('socket_id'); // SocketIdentifier
$areaId   = $ctx->get('area_id');   // AreaIdentifier
```

---

Pre-built Components
--------------------

[](#pre-built-components)

### 📜 Scripts

[](#-scripts)

Scripts are the core unit of logic. The library ships with both **atomic scripts** (single-responsibility steps) and **composition primitives** for building sequences and pipelines.

#### Composition primitives

[](#composition-primitives)

ScriptDescription`SequenceScript`Runs a list of scripts in order. Advances to the next when the current one succeeds. Fails immediately if any child fails, disconnects, or expires.`Pipeline`Fluent DSL for simple linear flows: `Pipeline::send($cmd)->waitFor(SomeEvent::class)->orFailOn(OtherEvent::class)`. Interchangeable with class-based scripts inside `SequenceScript`.#### Login sequence

[](#login-sequence)

ScriptDescription`LoginScript`Orchestrates the full login flow as a `SequenceScript` of three atomic steps (see below).`ConnectAndLoginScript`Sends `LoginCommand` on connection. On a successful `LoginRespondedEvent`, stores `socket_id` in context.`JoinBattleonScript`Sends `JoinInitialAreaCommand` on start. Succeeds when `AreaJoinedEvent` for `battleon` is received, storing `area_id` in context.`LoadInventoryScript`Sends `LoadPlayerInventoryCommand` on start (reading `socket_id` and `area_id` from context). Succeeds when `PlayerInventoryLoadedEvent` arrives.#### Base classes

[](#base-classes)

ClassWhen to use`AbstractScript`Base for all atomic scripts. Provides `success()`, `failed()`, `disconnected()`, `isDone()`, and a default no-op `start()`.`ExpirableScript`Extends `AbstractScript` with a configurable timeout.---

### ⚡ Events

[](#-events)

Events are strongly-typed objects produced from raw server messages. They represent things that happened on the server side.

EventTrigger`ConnectionEstablishedEvent`Server sent the cross-domain policy — connection is ready.`LoginRespondedEvent`Server replied to a login attempt.`AreaJoinedEvent`Player successfully joined a map.`PlayerDetectedEvent`A player entered or changed state in the current area.`PlayerInventoryLoadedEvent`Server finished sending the player's inventory.`PlayerLoggedOutEvent`Server confirmed the player's session was terminated.`AlreadyInAreaEvent`Player is already in the target area.`AreaLockedEvent`Target area is locked and cannot be joined.`AreaMemberOnlyEvent`Target area is restricted to members only.`AwayFromKeyboardEvent`Player status changed to AFK.`AreaNotAvailableEvent`Target area is currently unavailable.---

### 📦 Commands

[](#-commands)

Commands are actions sent from the client to the server. Each one knows how to serialize itself into the correct protocol format via `pack()`.

CommandDescription`LoginCommand`Authenticates a player using their username and token. First command sent after connection.`LogoutCommand`Gracefully terminates the player's session on the server.`JoinInitialAreaCommand`Moves the player to the initial area (`battleon`) right after login.`JoinAreaCommand`Transfers the player to a specific map and room instance.`LoadPlayerInventoryCommand`Requests the player's full inventory from the server.---

Extending
---------

[](#extending)

All core pieces are interface-driven, making the library easy to extend.

### Writing a custom script

[](#writing-a-custom-script)

Extend `AbstractScript`. Declare which events you handle in `handles()`, react in `handle()`, and optionally send an initial command from `start()`. Call `success()` or `failed()` when done.

```
final class MyScript extends AbstractScript
{
    #[Override]
    public function start(ClientContext $context): ?CommandInterface
    {
        return new SomeCommand(); // sent immediately before the loop
    }

    #[Override]
    public function handles(): array
    {
        return [SomeEvent::class, ErrorEvent::class];
    }

    #[Override]
    public function handle(EventInterface $event, ClientContext $context): ?CommandInterface
    {
        if ($event instanceof ErrorEvent) {
            $this->failed();
            return null;
        }

        $context->set('result', $event->data);
        $this->success();
        return null;
    }
}
```

### Using Pipeline for simple flows

[](#using-pipeline-for-simple-flows)

For common "send a command, wait for a response" patterns:

```
$step = Pipeline::send(new SomeCommand())
    ->waitFor(SuccessEvent::class)
    ->orFailOn(ErrorEvent::class);
```

`Pipeline` is fully compatible with `SequenceScript`:

```
$script = new SequenceScript([
    new ConnectAndLoginScript($name, $token),
    Pipeline::send(new JoinAreaCommand($area))->waitFor(AreaJoinedEvent::class),
]);
```

### Adding a new event

[](#adding-a-new-event)

Implement `EventInterface::from(MessageInterface): ?EventInterface`. Return `null` if the message doesn't match.

### Adding a new command

[](#adding-a-new-command)

Implement `CommandInterface::pack(): Packet`. Use `Packet::packetify()` with the `%xt%zm%cmd%...%` format.

### Custom socket

[](#custom-socket)

Implement `SocketInterface` — useful for testing or alternative transports.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance86

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

13

Last Release

67d ago

Major Versions

v2.0.1 → v3.0.02026-02-27

v3.0.5 → v4.0.02026-03-02

v4.0.1 → v5.0.02026-03-11

v5.0.0 → v6.0.02026-03-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/f7770f1974011e2b45f94474fa2d0ae50930ae8cb65eb38a77a41bbb1a5f0ac8?d=identicon)[dayvsonspacca](/maintainers/dayvsonspacca)

---

Top Contributors

[![dayvsonspacca](https://avatars.githubusercontent.com/u/64930283?v=4)](https://github.com/dayvsonspacca "dayvsonspacca (291 commits)")

---

Tags

aqwaqworldsphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dayvsonspacca-aqw-socket-client/health.svg)

```
[![Health](https://phpackages.com/badges/dayvsonspacca-aqw-socket-client/health.svg)](https://phpackages.com/packages/dayvsonspacca-aqw-socket-client)
```

###  Alternatives

[maglnet/composer-require-checker

CLI tool to analyze composer dependencies and verify that no unknown symbols are used in the sources of a package

99810.9M671](/packages/maglnet-composer-require-checker)[phpro/soap-client

A general purpose SoapClient library

8885.6M46](/packages/phpro-soap-client)[roave/backward-compatibility-check

Tool to compare two revisions of a public API to check for BC breaks

5953.3M56](/packages/roave-backward-compatibility-check)[veewee/xml

XML without worries

1835.9M29](/packages/veewee-xml)[php-soap/ext-soap-engine

An ext-soap engine implementation

443.2M7](/packages/php-soap-ext-soap-engine)[php-soap/engine

SOAP engine design

273.4M25](/packages/php-soap-engine)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
