Instant Messaging depends on room

131 views
Skip to first unread message

Marcus Hellner

unread,
May 28, 2014, 6:23:17 AM5/28/14
to eas...@googlegroups.com
Hello,

i have got an issue with the insatnt messaging. I have merged video chat and text chat on one site.
So if 2 participants are in a chat and sending text messages, a third one which is in another room can see the messages which are sent.

attached you find my main.js

function connect() {
    easyrtc.setSocketUrl(":8010");
    easyrtc.enableDebug(true);
    easyrtc.enableAudio(true);
    easyrtc.enableVideo(true);
    joinRoom();
    easyrtc.setRoomOccupantListener(loggedInListener);
    easyrtc.setPeerListener(addToConversation);
    easyrtc.easyApp("AudioVideoChat", "self", ["caller"],
            function(myId) {
                //console.log("My easyrtcid is " + myId + " and Username: " + benutzername);
            }
    );
}


function loggedInListener(roomName, otherClients, myInfo) {
    var easyrtcid_Owner = myInfo.easyrtcid; // tmp
    var roomJoinTime_Owner = myInfo.roomJoinTime; // tmp

    var iamOwner = true;
    var aClient;
    var selfVideo = document.getElementById("self");
    var callerVideo = document.getElementById("caller");

    for (aClient in otherClients) {
        if (aClient === otherClients[0]) {
            easyrtc.setUsername("Kunde");
        } else {
            easyrtc.setUsername("Agent");
        }
        if (myInfo.roomJoinTime > otherClients[aClient].roomJoinTime) {           
            iamOwner = false;
        }
        document.getElementById("sendMessageText").onkeydown = function(event) {
            if (event.keyCode === 13) {
                sendStuffWS(aClient); // Message senden
            }
            ;
        };
    }

    if (iamOwner === true) {
        selfVideo.style.display = "block";
        callerVideo.style.display = "block";
    }
    else
    {
        selfVideo.style.display = "block";
        callerVideo.style.display = "block";

        for (aClient in otherClients) {
            if (roomJoinTime_Owner > otherClients[aClient].roomJoinTime) {
                roomJoinTime_Owner = otherClients[aClient].roomJoinTime;
                easyrtcid_Owner = otherClients[aClient].easyrtcid;
            }
        }

        performCall(easyrtcid_Owner);
    }
}



function addToConversation(otherEasyrtcid, msgType, content) {
    // Escape html special characters, then add linefeeds.
    content = content.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
    content = content.replace(/\n/g, '<br />');
    var newText = document.createElement("div");
    newText.innerHTML = "<b>" + easyrtc.idToName(otherEasyrtcid) + ":</b>&nbsp;" + links(content) + "<br />";
    document.getElementById("conversation").appendChild(newText);
    newText.scrollIntoView();
    //document.getElementById('conversation').innerHTML +="<b>" + easyrtc.idToName(otherEasyrtcid) + ":</b>&nbsp;" + links(content) + "<br />";
}

function sendStuffWS(otherEasyrtcid) {
    var text = document.getElementById('sendMessageText').value;
    if (text.replace(/\s/g, "").length === 0) { // Don't send just whitespace
        return;
    }

    easyrtc.sendDataWS(otherEasyrtcid, "message", text);
    addToConversation(easyrtc.idToName(easyrtc.myEasyrtcid), "message", text);
    document.getElementById('sendMessageText').value = "";
}

Eric Davies

unread,
May 29, 2014, 3:37:35 PM5/29/14
to eas...@googlegroups.com
Hi Marcus,

What is it you are trying to do?
How are you trying to do it?
What are you seeing happen?

Eric.

Marcus Hellner

unread,
Jun 19, 2014, 8:14:47 AM6/19/14
to eas...@googlegroups.com
Thanks for youre response. I have got an issue on connection to easyrtc.app.
I have solved this.

Thanks

Jordan Martins

unread,
May 22, 2015, 4:59:45 AM5/22/15
to eas...@googlegroups.com
Hello Marcus,

You solved the problem, however forgot to share.

For example, I'm having the same problem as you.
My Text Chat only sends directed to one person.

I would like to have both options:
Private and everyone in the room.

Eric Davies

unread,
May 22, 2015, 10:05:31 AM5/22/15
to eas...@googlegroups.com
Try http://demo.easyrtc.com/demos/demo_instant_messaging_rooms.html for demonstration of this ability.
Examine the code to see how it's done.

Jordan Martins

unread,
May 22, 2015, 10:09:08 AM5/22/15
to eas...@googlegroups.com
Thank you friend ... I will dwell on the .js this demo.
Reply all
Reply to author
Forward
0 new messages