hoaproject / Websocket

The Hoa\Websocket library.
https://hoa-project.net/
422 stars 75 forks source link

Creating topics for classified of broadcasting message... #52

Closed YnievesDotNet closed 9 years ago

YnievesDotNet commented 9 years ago

Creating topics for classified of broadcasting message

Hello again. Other things is about the creation of topics, of thread for sending message at one or more groups of recipients, for example, create some tags, example, notify.admins, chat.public, chat.private.{thread_id}, etc, and opened this threads from the javascript client, and validate this connect using php. For example:

use HoaTopic;
...
    public function getLogin()
    {
        HoaTopic::send('Login rendered', 'notify.admin');
        return view('auth.login');
    }
...

and in the class HoaWebSocket, or other, do this.

class HoaTopic extend HoaWebSocket {
    ...
    public function send($message, $topic) {
        $user = Sentinel::getUser();
        if ($topic == 'notify.admin') {
            if (!$user->hasAccess('admin')) {
                self::send('Access Denied at user '.$user->id, 'notify.admin');
                return;
            }
            $nodes = $bucket->getSource()->getTopics($topic)->getConnection()->getNodes();
            foreach ($nodes as $node) {
                $node->send($message);
            }
        }
    }
    ...
}

Thanks

YnievesDotNet

Hywan commented 9 years ago

Hello :-),

Is it a new feature request? If so, I reckon this is not the goal of the Hoa\Websocket library to implement this. We do support the WebSocket protocol. Consequently we have listeners for message, binary-message etc. Channels are not part of the WebSocket protocol. However, it may be related to https://github.com/hoaproject/Websocket/issues/26?

YnievesDotNet commented 9 years ago

exactly, this is a feature wamp, and is related at issue 26. send one message at one specific client or group of clients. Like as Private Chat or Grouped Broadcasting, etc.

Thanks

YnievesDotNet

Hywan commented 9 years ago

This can be accomplished by using nodes and the broadcastIf method. It can also be down by using WAMP but this latter protocol is not implemented yet.