These are chat archives for oncesk/yii-node-socket

24th
Aug 2015
oncesk
@oncesk
Aug 24 2015 13:51

hi =)

is anybody here?)

KirillRyzhkov
@KirillRyzhkov
Aug 24 2015 13:52
Hi, привет
oncesk
@oncesk
Aug 24 2015 13:52
привет
я сегодня попробую структуру на бумажке нарисовать того что было бы круто запилить
Rjgoolsby
@Rjgoolsby
Aug 24 2015 13:52
Hi
oncesk
@oncesk
Aug 24 2015 13:52
сфоткаю и покажу)
KirillRyzhkov
@KirillRyzhkov
Aug 24 2015 13:53
ок, это доработка этого расширения или новое что-то?
oncesk
@oncesk
Aug 24 2015 13:53
давай на английском)
no this is a new tool
network tool
KirillRyzhkov
@KirillRyzhkov
Aug 24 2015 13:54
Is it related to Yii2?
oncesk
@oncesk
Aug 24 2015 13:54
yes if we are implement support for it
it is a standalone tool which can be used on any language and on php
Rjgoolsby
@Rjgoolsby
Aug 24 2015 13:55
What language?
KirillRyzhkov
@KirillRyzhkov
Aug 24 2015 13:55
What is the purpose of it. Real-time communication?
Rjgoolsby
@Rjgoolsby
Aug 24 2015 13:55
ok
oncesk
@oncesk
Aug 24 2015 13:55
programming language
with this we will can write more powerfull realtime application and handle some work on any language
Rjgoolsby
@Rjgoolsby
Aug 24 2015 13:56
Yes programming language. What will it be written in?
KirillRyzhkov
@KirillRyzhkov
Aug 24 2015 13:56
That sounds interesting
oncesk
@oncesk
Aug 24 2015 13:56
we can use queue for transport some task to our worker which can be writen on any language
we can use more than one nodejs server
we can write workers on php or java or nodejs
KirillRyzhkov
@KirillRyzhkov
Aug 24 2015 13:57
So you think there is no alternatives or similar tools right now?
oncesk
@oncesk
Aug 24 2015 13:58
i do not know about it, i know thrift and etc tools but they are usefull for other purposes
KirillRyzhkov
@KirillRyzhkov
Aug 24 2015 13:58
ok
oncesk
@oncesk
Aug 24 2015 13:59
we can create event loop server which can be elastic and flexible.
Rjgoolsby
@Rjgoolsby
Aug 24 2015 13:59
interesting
oncesk
@oncesk
Aug 24 2015 14:00
configuration of the node (nodejs) we can store in some db, after when node is starting they are read all nodes and write your own configuration to db, between nodes exists a queues, for input and output
something like this
Rjgoolsby
@Rjgoolsby
Aug 24 2015 14:01
This would be useful
oncesk
@oncesk
Aug 24 2015 14:01
i will design it more in more simple
and show you
KirillRyzhkov
@KirillRyzhkov
Aug 24 2015 14:02
Ok, will be waiting for it
oncesk
@oncesk
Aug 24 2015 14:02

we can create something like a

subscription
subscriber
subscription_subscriber

and all income connection will note to connect to any room, before connect we should login in some channel or room

this is authentication mechanism
and we can add some user in channel from any language, php, nodejs, ruby just add it to the db table
we can think and discuss about it
Rjgoolsby
@Rjgoolsby
Aug 24 2015 14:04
I'm currently working on something similar for a client with node.js. This may be a better solution.
oncesk
@oncesk
Aug 24 2015 14:04
yesterday i had idea which any worker can create some command, like a publish it, and on client side we can invoke this command, this is only like idea=)
Rjgoolsby
@Rjgoolsby
Aug 24 2015 14:07
This is awesome.
I can work with this side by side with my main project
When you have a design ready, let me know. I'd like to see it
oncesk
@oncesk
Aug 24 2015 14:13
Ok, try to do this today
oncesk
@oncesk
Aug 24 2015 19:41

sorry, but today i am tired and i can not create some diagrams =( but i can now explain main principles:

Definitions:

  • node - instance of nodejs server
  • queue - queue by default is gearman
  • worker - standalone code which should accept and handle some commands, like write message to db and send to all clients
  • db - data base

Node set up process:
Every node has configuration as ip(domain) and queue for listen in gearman is a callback function name. This configuration we are store in db. When new instance is setting up it configuration should be updated. Every worker can read nodes configuration and update it every 5 min for example, when we need to send data to all clients we must send it to all nodes to their callbacks (in gearman). Why? Because we can have two clients: John and Sara, John and Sara in room for example megaroom, but john connected to server 1 and sara connected to server 2, when john send message to sara sara situated in other server we must send message to Sara. This problem can be decided by sending message to all nodes in concrete channel.

Worker language:
Worker language can be php,nodejs,c,ruby and etc

Web Client:
Javascript web client can call some methods on workers and some predefined methods as emit and etc. Here we need to think... have some problems

Authentication and Authorization:
I think the simplest way to do authorizaation is a store channel, subscriber, and channel subscriber like in yii-node-socket.
Usecase: backend like a php can create some channel and can create some subscribers, can subscribe some subscriber to channel with the project business rules.
In this case we can have some connections which not be in some channel, this is not authenticated connections and can listen public channel.
For authorization we should store session id in cookie and in session, the best way to do that it is use a dedicated store like redis for session. As a minus in some cases we are need to open web session in our worker in this case, as i see, we can do that.

Send event from php (language for example):
For send message to all clients we should already set task to all queues with some data and that is all what we should do for send message.

Framework support:
We need to write abstract php code - standalone library which can be used for adapt tool for frameworks. Yii,yii2, symfony2 and etc...

Overall:
With this system we can:

  • create more than one node
  • create many workers
  • simple send events from web backend or frontend
  • simple authentication

I am open for discussion and proposal. I really do not know if something exists for the web.

in this tool nodejs need already for keep connections and send some data, event loop