Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

ZeqaNetwork/ZeberClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ZeberClient

Usage

  • Connecting
$serverName = "AS1-Practice";
$ip = "127.0.0.1";
$port = 5770;
$zeber = new ZeberClient($serverName, $ip, $port);
  • Sending Packet
/** @var ZeberClient $zeber */
$zeber->sendPacket(
    ForwardBuilder::create($serverName, "AS2-Practice", [
        "action" => "broadcast_message",
        "message" => "hi everyone!"
    ])
);
  • Handling Packet
/** @var ZeberClient $zeber */
$handler = new MyZeberPacketHandler($zeber);
$zeber->setHandler($handler);
class MyZeberPacketHandler extends \ZeqaNetwork\ZeberClient\ZeberPacketHandler{

    public function handle(string $id, mixed $data){
        switch($id) {
            case PacketId::FORWARD:
                switch($data["action"]) {
                    case "broadcast_message":
                        $message = $data["message"];
                        Server::getInstance()->broadcastMessage($message);
                        break;
                }
                break;
        }
    }
}
  • Close
/** @var ZeberClient $zeber */
$zeber->close();

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages