PHP code example of dayvsonspacca / aqw-socket-client

1. Go to this page and download the library: Download dayvsonspacca/aqw-socket-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dayvsonspacca / aqw-socket-client example snippets


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

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

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;
    }
}

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

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