Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to Publish data from REDIS instead of file ? #22

Closed
KabDeveloper opened this issue Jun 11, 2019 · 9 comments
Closed

Is it possible to Publish data from REDIS instead of file ? #22

KabDeveloper opened this issue Jun 11, 2019 · 9 comments
Labels

Comments

@KabDeveloper
Copy link

KabDeveloper commented Jun 11, 2019

Hi,

I want to send data from REDIS server to the websocket server and then post to BROWSER.

Is it possible instead of using a file ?

What is the part of the code responsible to read the file and send the data to client ?

Last thing, can i compile it in WINDOWS ?

WSS secured connection supported ?

Thank's in advance.

@allinurl
Copy link
Owner

You should be able to. But it depends how redis outputs its data. gwsocket simply uses a file descriptor, so you could handle it differently in here. Do you know how redis outputs the results? If you could pipe the results of a command then you are golden...

@KabDeveloper
Copy link
Author

Thank you for your answer !

I think it's possible to implement REDIS using your script, here is the REDIS client in C:
https://github.com/EulerianTechnologies/eredis
OR one of this clients:
https://redis.io/clients#c

Since my level in C is very low, it would be possible to catch new entered values on REDIS using this code in PHP:

$r = new Redis();
$r->connect("127.0.0.1", "6379");

while(true){
    while($xdata = $r->spop("data_pipe")){
        $data = unserialize($xdata);

        // Send the data
        // Here a code to send the data to client's browser
    }

    // No more data
    sleep(30);
}

What is the part of your code that is responsible to read the file and return the LINE & Send it ?

Thank you again

@allinurl
Copy link
Owner

If you want to handle this with PHP, you could keep doing what you are doing and output the data in PHP to the gwosocket fifo. It should work fine. Please take a look at these examples

@KabDeveloper
Copy link
Author

KabDeveloper commented Jun 11, 2019

I already checked that, but fetching datas from REDIS and then writting them each time to a file will take more time than returning them directly from REDIS to websocket.

Since there a way doing it in C then i bet on this, i need only to identify the part of code responsible to:
1- Read the file line by line
2- The code that return the line and then send it to websocket

There will be many users interested on this combination, with small help i will be able to achieve this and post it here or in a fork.

Thank's :)

@allinurl
Copy link
Owner

It's all in here. Reads, writes and accept. Let me know how it goes. Thanks.

@KabDeveloper
Copy link
Author

Thank you for your help !

Last question please, when your script read the lines from the file ... do it remove the lines when it send it to the clients ?

@allinurl
Copy link
Owner

Yes it does that automatically.

@KabDeveloper
Copy link
Author

What is the line responsible for doing that please ?

What if new lines added while he is sending to clients ? There will be no disfunction or no error ?

@allinurl
Copy link
Owner

What is the line responsible for doing that please ?

https://github.com/allinurl/gwsocket/blob/master/src/websocket.c#L532

What if new lines added while he is sending to clients ? There will be no disfunction or no error ?
It will handle that just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants