How to open a chat window in sender and receiver side [on hold]
- by DEEPS
When i am trying to send a message from sender the chat window is always opening in senders side instead of receiver side.so please give a correct code to display chat box in both side.
(HTML 5, JAVASCRIPT,JQUERY).
This is client side code:
//Send private message
function sendPvtMsg(data)
{
var pvtmsg = data;
socket.emit('message',JSON.stringify({msg: 'pvtMsg',
data: {
from: userName,
to: toChat,
pvtmsg: data
}}),roomId);
}
socket.on('message',function(data)
{
var command = JSON.parse(data);
var itemName = command.msg;
var rec_data = command.data.message;
var sender = command.data.name;
//Receive message from server
if (itemName == "message")
{
document.getElementById("chat").value += sender + " : " + rec_data + "\n";
}
//Receive private message
else if (itemName == "pvtMsg")
{
var to = command.data.to;
var from = command.data.from;
//To display message to sender and receiver
if (userName == to || userName == from)
{
var pvtmsg = command.data.pvtmsg;
document.getElementById("chat").value += from + "( to " + to + ")" + " : " + pvtmsg + "\n";
}
}
function createChatBox(chatboxtitle,minimizeChatBox) {
if ($("#chatbox_"+chatboxtitle).length > 0) {
if ($("#chatbox_"+chatboxtitle).css('display') == 'none') {
$("#chatbox_"+chatboxtitle).css('display','block');
restructureChatBoxes();
}
$("#chatbox_"+chatboxtitle+" .chatboxtextarea").focus();
return;
}