Skip to content

Server Application, Samples

cumulusdev edited this page Dec 1, 2012 · 13 revisions

Meeting sample

capture1 Capture2

The sources are available here: http://www.adobe.com/devnet/flashmediaserver/articles/real-time-collaboration.html

Use only the client part of these souces, and for server side create the file CumulusServer/www/meeting/main.lua with the following content:

	function onStart(path)
		NOTE("Application '"..path.."' started")
	end

	function onStop(path)
		NOTE("Application '"..path.."' stopped")
	end

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

		INFO("User connected: ", client.userName , "meeting: ", client.meeting);
		
		function client:getParticipants(meeting)
			result = {}
			i = 0;
			for key, cur_client in cumulus.clients:pairs() do
				if (cur_client.meeting == meeting) then
					i = i+1;
					participant = {};
					participant.userName = cur_client.userName;
					participant.meeting = cur_client.meeting;
					if cur_client.id then
						participant.protocol = 'rtmfp';
					end
					participant.farID = cur_client.id;			
					result[i] = participant;
				end
			end	
			return result;
		end
			
		function client:sendMessage(meeting, from, message)
			for key, cur_client in cumulus.clients:pairs() do
				if (cur_client.meeting == meeting) then		
					cur_client.writer:writeAMFMessage("onMessage", from, message);
				end
			end
		end

		sendParticipantUpdate(client.meeting);
	end

	function onDisconnection(client)
		INFO("User disconnecting: "..client.userName);
		sendParticipantUpdate(client.meeting);
	end

	function sendParticipantUpdate(meeting)
		for key, cur_client in cumulus.clients:pairs() do
			if (cur_client.meeting == meeting) then		
				cur_client.writer:writeAMFMessage("participantChanged");
			end
		end
	end
Clone this wiki locally