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

How can we send the logged in user id #9

Open
manojdhiman opened this issue Feb 20, 2015 · 10 comments
Open

How can we send the logged in user id #9

manojdhiman opened this issue Feb 20, 2015 · 10 comments

Comments

@manojdhiman
Copy link

hi , first of all thanx for this code. i am using this library to implement a chat application , problem is how can i send the logged in user id when a user connects to socket with function

Server.bind('open', function(data)
{
var user='user->name); ?>';
alert(data);
});

@jignesh87
Copy link

I aso wants to perform this task.
any idea?

@manojdhiman
Copy link
Author

i implemented this task but not sure it is secure or not .. :p

if you want to check then server side file is https://github.com/manojdhiman/yii-login-register-with-chat/tree/master/chat_server

and client side https://github.com/manojdhiman/yii-login-register-with-chat/blob/master/themes/basic/views/layouts/main.php

please check this is just a try if you can improve this

@jignesh87
Copy link

hiii..manoj
I have created function in Server.php
function getServerData(){

$sql = "SELECT id, user_name FROM user_master";

$result = mysqli_num_rows($conn, $sql);

if ($result->num_rows(result) > 0) {
    while($row = mysqli_fetch_assoc($result)) {
        $d = "id: " . $row["id"]. " - UName: " . $row["user_name"]. "<br>";die;
    }
}else{
    $d = "0 results";
}
return $d;

}
which is called when client == 1
if ( sizeof($Server->wsClients) == 1 ){
echo getServerData();
$Server->wsSend($clientID, "It's server!!");
}
when i refresh connection becomes diconnect, and it returns nothing.
Is there any prob?.

I wants to send data instead of message.
Thanks .
Jignesh

@manojdhiman
Copy link
Author

it should reconnect if you refresh the page .check your terminal after refresh the page with print something on close event like

function wsOnClose($clientID, $status) {
global $Server;
$ip = long2ip( $Server->wsClients[$clientID][6] );

$Server->log( "$ip ($clientID) has disconnected." );

}

@jignesh87
Copy link

Hii,Manoj
I have done server response sucessfully.
One issue is when i try sending data from server as a video file it crashes my cmd,
and it's not responding.
Is it any way to send video from server side to the client?
Thank you,
Jignesh.

@hamidteimouri
Copy link

Hi,
I use websocket, but i wanna send msg to 1 person, not to all,

can u help me ?

@juanjosv
Copy link

Hi,
I use websocket, but i wanna send msg to 1 person, not to all,
can u help me ?

And not only that, i'm trying to hide the message if anyone connect to that websocket, only show the message to the person i want

@hamidteimouri
Copy link

Hi,
I use websocket, but i wanna send msg to 1 person, not to all,
can u help me ?

And not only that, i'm trying to hide the message if anyone connect to that websocket, only show the message to the person i want

This was for 2 years ago.
I fixed it !

@juanjosv
Copy link

Hi,
I use websocket, but i wanna send msg to 1 person, not to all,
can u help me ?

And not only that, i'm trying to hide the message if anyone connect to that websocket, only show the message to the person i want

This was for 2 years ago.
I fixed it !

Oh, sorry, i found this project and using it to develop a chat system , and i'm stuck in the same case.

@hamidteimouri
Copy link

Hi,
I use websocket, but i wanna send msg to 1 person, not to all,
can u help me ?

And not only that, i'm trying to hide the message if anyone connect to that websocket, only show the message to the person i want

This was for 2 years ago.
I fixed it !

Oh, sorry, i found this project and using it to develop a chat system , and i'm stuck in the same case.

You should use node js for that.
PHP socket is not good for socket programming.

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

No branches or pull requests

4 participants