Download the PHP package zeus/pusher without Composer
On this page you can find all versions of the php package zeus/pusher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package pusher
Socket Channels
This is a socket library, it is an advanced library, the purpose of which is to subscribe to channels on the socket and send messages to channels, as well as leaving channels...
for install
Socket Server Management
We manage the entire socket server with an object inherited from the AbstractSocketClientHandler object... In the example below, it is the ClientHandler object, but this is entirely up to your wishes. Let's, For example, let's send the message to everyone.
server.php
Run in the Terminal
js websocket code
Works with the wildcard
You can use wildcard in channel management. Here, the join method is subscribing to the channel, at the same time, you can use the leave method to cancel the subscription to the channel, you can subscribe to the channels and receive notifications, in fact, the main logic is like a real scenario and if we want to give up notifications to the channels, we use the leave method, that's all.
Additionally, there are more methods besides methods such as hasJoin, join and leave,this is purely for managing channels well...
In the example below, we subscribe to it.backend
and it.frontend
channels and the beginning is it.
We send notifications to all channels that start,
the purpose here is to group the channels.
First of all, we use the $this->getClient()
method to get the connected client...
Clients of a channel
You can get all the clients subscribed to a channel for example by default, all clients are subscribed to the channel named public.
You can receive all channels in the system and attract clients connected to these channels and perform transactions.
Some methods for the channel, but don't forget there are more
note: leave method does not support wildcard for now. it will not working,I thought this was not appropriate due to its completely irreversible effects
Works with the json
Let's subscribe to the channels with the json coming from the frontend and send messages to the channels. js code
This example subscribes to the channel according to the json data coming from the clients and sends the message to the subscribed channel.
In the frontend
In the Backend
The client
The php client does not listen to the socket, so what is the purpose?
It allows sending messages to connected connections. You can even make this client compatible with the API and send messages to language-independent sockets.
This code forwards the message to the connected server and closes the connection. In this way, it provides incredible flexibility, you can even create an API socket server, yes, it sounds nice, doesn't it?
Send a custom message
You can send a message to a special client, for example, let's send a message only to the currently connected client.
Send a message by socket id
The socket ID can be used to send a custom message. Below is an example of sending a message to a specific socket ID. A feature designed especially for sending personal messages.
Websocket routes
You can create a namespace using js websocket and route path, below are examples of js and php codes.
javascript websocket
is Route and hasRoute methods
-
hasRoute: Is there any client connecting via /chat route?.
- isRoute: Is the current client connected via the /chat route?.
The host address of the client
Let's disconnect the socket connection of an ip address
You can get the host or IP address of the connected client.
In this way, you can deny an IP address, for example, let's disconnect a client whose IP value is x.x.x.x.
Get the status of the client
You can get any client status
For more information
Now, if you want to add Channel Broadcast and Send classes, there is a way to do this. For example, let's create a method for Send and use it.
If you pay attention, the 'test' and 'empty' methods do not actually exist, we simulated them as if they existed.
to be continued...
[|||||||||||||||]