PHPWebSocket-Chat
PHPWebSocket-Chat copied to clipboard
How can we send the logged in user id
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); });
I aso wants to perform this task. any idea?
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
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
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." );
}
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.
Hi, I use websocket, but i wanna send msg to 1 person, not to all,
can u help me ?
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
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 !
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.
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.