Meeting LUA Script Modification for DoubleName

64 views
Skip to first unread message

Gerd Hilgemann

unread,
Oct 4, 2013, 8:26:26 AM10/4/13
to openrtmf...@googlegroups.com
Hi,

playing with the meeting room lua script a little bit.

I have seen that when a user came in with the same name, there is disable on the client site or a script on the server side for detecting this.

Here is my first idea of fixing it on the culumus server side, i´m coming from the C world and its strange to see that i can define a variable without specifing it, see userExits :)

You have to include this in the main.lua script in your culumus www/yourmeetingroom.lua (<-only for example).

In this version i add a math random and a YOU identify, let me know if there is a better way to handle this.

-
function onConnection(client, userName, meeting)
   
    client.userName = userName;
    client.meeting = meeting;

    INFO("User connected: ", client.userName , "meeting: ", client.meeting);
    userExits = 0;
               
    for key, cur_client in cumulus.clients:pairs() do
       
        if (cur_client.meeting == meeting) then
            print(cur_client.userName);
            if (cur_client.userName == userName) then
                userExits = 1;
            end
        end
    end
   
    if (userExits == 1) then
        userName         = userName .. "_" .. math.random(1,1000) .. " (YOU)";
        client.userName = userName;
    end


Mathieu Poux

unread,
Oct 4, 2013, 8:49:57 AM10/4/13
to openrtmf...@googlegroups.com
Hi, 

I don't understand the "meeting" variable goal, but you avoid simply a duplicated name, following a short code to do that:

AS3

_netConnection.connect("rtmfp://localhost/?name=Client1");

LUA

_clients = {}
function onConnection(client)
if _clients[client.name] then error("Client "..client.name.." already connected!") end
_clients[client.name] = client
end
function onDisconnection(client)
_clients[client.name] = nil
end

Gerd Hilgemann

unread,
Oct 4, 2013, 8:59:42 AM10/4/13
to openrtmf...@googlegroups.com

the meeting var is for the room of the meeting. there can a user with a name "joe" exit in meeting_room1 as well another "joe" in meeting_room2.

if the meeting i would like to check if i hit the right user.

but i´m thinking right now what happend if a user is connected to two different rooms at the same time with the same name, i dont think that is  a problem will figure it out.. :)

thankx for you code, will try that.

Mathieu Poux

unread,
Oct 8, 2013, 1:53:23 AM10/8/13
to openrtmf...@googlegroups.com
Ok I see, so:

AS3
_netConnection.connect("rtmfp://localhost/?name=myName&room=myRoom");

LUA
_rooms = {}
function onConnection(client)
local members = _rooms[client.room]
if members then
if members[client.name] then error(client.name.." already connected in room "..client.room) end
else
members = _rooms[client.room] = {}
end
members[client.name] = client
end
function onDisconnection(client)
local members = _rooms[client.room]
members[client.name] = nil
for _ in pairs(members) do
return -- always some members, don't erase the room
end
-- no members, erase the room
_rooms[client.room] = nil
end

Gerd Hilgemann

unread,
Oct 8, 2013, 8:50:08 AM10/8/13
to openrtmf...@googlegroups.com
great! thanks a lot! 
Reply all
Reply to author
Forward
0 new messages