DCWatch BCDC Bridge 0.2.5.061006

Post finished Hubside Scripts here, known supporting hubsofts for LUA scripting.

ADCH++ | DCWatch | LUADCH
Post Reply
Toast

DCWatch BCDC Bridge 0.2.5.061006

Post by Toast » 10 Feb 2008, 09:45

Code: Select all

-- DCWatch Lua Engine
-- BCDC Bridge 0.2.5.061006
dcwatch:show( "", "# DCWatch Lua Engine - BCDC++ Bridge" )

BCDC = {}

DC = function()
	return BCDC
end

BCDC.CreateClient = function( this )
	return 0
end

BCDC.DeleteClient = function( this )
	return 0
end

BCDC.FindWindowsHandle = function( this )
	return 0
end

BCDC.GetAppPath = function( this )
	return dcwatch:getPath().."/"
end

BCDC.GetHubIpPort = function( this, hubid )
	local hub = dcwatch:getHubManager():getHubByHost( hubid )
	local address = hub:getHubSettings():getIp() .. ":" .. hub:getHubSettings():getPort()
	return address
end

BCDC.GetHubUrl = function( this, hubid )
	local hub = dcwatch:getHubManager():getHubByHost( hubid )
	local address = hub:getHubSettings():getFullHost()
	if hub:getHubSettings():getProtocolType() == 0 then
		return "dchub://" .. address
	else
		return "adc://" .. address
	end
end

BCDC.HubWindowAttention = function( this, hubid )
	return 0
end

BCDC.InjectHubMessage = function( this, hubid, message )
	dcwatch:show( hubid, message )
	return 0
end

BCDC.InjectHubMessageADC = function( this, hubid, message )
	dcwatch:show( hubid, message )
	return 0
end

BCDC.PrintDebug = function( this, message )
	dcwatch:show( "", message )
	return 0
end

BCDC.RunTimer = function( this, enabled )
	if enabled == 0 then
		return dcwatch:disableTimer()
	else
		return dcwatch:enableTimer()
	end
end

BCDC.SendHubMessage = function( this, hubid, message )
	local hub = dcwatch:getHubManager():getHubByHost( hubid )
	hub:sendData( message )
	return 0
end

BCDC.SendUDP = function( this, ip_port, message )
	return 0
end

BCDC.SendWindowMessage = function( this )
	return 0
end

dofile( dcwatch:getPath() .."/scripts/startup.lua" )

dcwEvents = {}

function dcwEvents.doCommandReceived( hub_id, command )
	local hub = dcwatch:getHubManager():getHubByHost( hub_id )
	if hub:getHubSettings():getProtocolType() == 0 then
		nmdch.DataArrival( hub_id, command )
	else
		adch.DataArrival( hub_id, command )
	end
end

function dcwEvents.doConnect( hub_id )
	local hub = dcwatch:getHubManager():getHubByHost( hub_id )
	if hub:getHubSettings():getProtocolType() == 0 then
		nmdch.OnHubAdded( hub_id )
	else
		adch.OnHubAdded( hub_id )
	end
end

function dcwEvents.doDisconnect( hub_id )
	local hub = dcwatch:getHubManager():getHubByHost( hub_id )
	if hub:getHubSettings():getProtocolType() == 0 then
		nmdch.OnHubRemoved( hub_id )
	else		
		adch.OnHubRemoved( hub_id )
	end
end

function dcwEvents.doTimer()	
	dcpp.OnTimer()
end

dcwEventsProxy = luajava.createProxy( "org.dccafe.dcwatch.plugins.lua.LuaEventHandlerInterface", dcwEvents )
dcwatch:addEventHandler( "BCDC Bridge 0.2.5.061006", dcwEventsProxy )

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests