
Server = {};
Server_mt = Class(Server, Event);
InitEventClass(Server, "Server");

function Server:emptyNew()
    local self = Event:new(Server_mt);
    return self;
end;
function Server:new()
    local self = Server:emptyNew();		
    return self;
end;

function Server:readStream(streamId, connection)

	g_currentMission.FarmingTablet.Bank.Kredit1.active = streamReadBool(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit1.zinsenPerDay = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit1.insgesamt = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit1.tag = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit1.ueberzogen = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit2.active = streamReadBool(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit2.zinsenPerDay = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit2.insgesamt = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit2.tag = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit3.active = streamReadBool(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit3.zinsenPerDay = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit3.insgesamt = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit3.tag = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Anlegen.on = streamReadBool(streamId);
	g_currentMission.FarmingTablet.Bank.Anlegen.money = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Anlegen.tage = streamReadInt32(streamId);
	g_currentMission.FarmingTablet.Bank.Anlegen.tag = streamReadInt32(streamId);
	
	--local numApps = streamReadInt32(streamId);
	--g_currentMission.FarmingTablet.Appstore.apps = {};
	--for i = 1, numApps do
	--	g_currentMission.FarmingTablet.Appstore.apps[i] = streamReadBool(streamId);
	--end;
	
end;

function Server:writeStream(streamId, connection)

	streamWriteBool(streamId, g_currentMission.FarmingTablet.Bank.Kredit1.active);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit1.kredithoehe);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit1.zinsenPerDay);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit1.laufzeit);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit1.insgesamt);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit1.tag);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit1.ueberzogen);
	streamWriteBool(streamId, g_currentMission.FarmingTablet.Bank.Kredit2.active);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit2.kredithoehe);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit2.zinsenPerDay);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit2.laufzeit);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit2.insgesamt);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit2.tag);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit2.ueberzogen);
	streamWriteBool(streamId, g_currentMission.FarmingTablet.Bank.Kredit3.active);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit3.kredithoehe);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit3.zinsenPerDay);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit3.laufzeit);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit3.insgesamt);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit3.tag);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Kredit3.ueberzogen);
	streamWriteBool(streamId, g_currentMission.FarmingTablet.Bank.Anlegen.on);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Anlegen.money);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Anlegen.tage);
	streamWriteInt32(streamId, g_currentMission.FarmingTablet.Bank.Anlegen.tag);
	
	--local numApps = table.getn(g_currentMission.FarmingTablet.Appstore.apps)
	--streamWriteInt32(streamId, numApps);
	--for i = 1, numApps do
	--	streamWriteBool(streamId, g_currentMission.FarmingTablet.Appstore.apps[i]);
	--end;
	
	
end;
function Server:run(connection)
	
end;