PHP code example of nadybot / aolib

1. Go to this page and download the library: Download nadybot/aolib 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/ */

    

nadybot / aolib example snippets


 declare(strict_types=1);

use function Amp\Socket\connect;

use Monolog\Handler\StreamHandler;
use Monolog\Processor\PsrLogMessageProcessor;
use Monolog\{Level, Logger};

et = connect("chat.d1.funcom.com:7105");
$client = new \AO\Client\Basic(
    $logger,
    new \AO\Connection($logger, $socket, $socket);
    \AO\Parser::createDefault($logger)
);
$client->login(username: "Myuser", password: "Mypassword", character: "Mychar");
while (($package = $client->read()) !== null) {
  // Process package
}

$uid = $client->lookupUid("Nady");
$character = $client->lookupCharacter(123456);

$client->write(new Out\Tell(charId: 1234, message: "Hello!"));

 declare(strict_types=1);

use AO\Client\{Multi, WorkerConfig};

    new WorkerConfig(
            dimension: 5,
            username: "login1",
            password: "password1",
            character: "Char1",
        ),
        new WorkerConfig(
            dimension: 5,
            username: "login2",
            password: "password2",
            character: "Char2",
        ),
    ]
);

$client->login();

foreach ($client->getPackages() as $package) {
    // Do something
}

EventLoop::run();