setlogSplitterEvent = {}
local setlogSplitterEvent_mt = Class(setlogSplitterEvent, Event)

InitEventClass(setlogSplitterEvent, "setlogSplitterEvent")

function setlogSplitterEvent.emptyNew()  
    local self = Event.new(setlogSplitterEvent_mt)

    return self
end

function setlogSplitterEvent.new(vehicle, state) 
    local self = setlogSplitterEvent.emptyNew()
	self.vehicle = vehicle
    self.state = state
	
    return self
end

function setlogSplitterEvent:readStream(streamId, connection)  
    self.vehicle = NetworkUtil.readNodeObject(streamId) 
    self.state = streamReadBool(streamId)
	
    self:run(connection)
end

function setlogSplitterEvent:writeStream(streamId, connection)   
	NetworkUtil.writeNodeObject(streamId, self.vehicle)
    streamWriteBool(streamId, self.state )
end

function setlogSplitterEvent:run(connection) 
    self.vehicle:setlogSplitter(self.state, true)
	
    if not connection:getIsServer() then  
        g_server:broadcastEvent(setlogSplitterEvent.new(self.vehicle, self.state), nil, connection, self.object)
    end
end

function setlogSplitterEvent.sendEvent(vehicle, state, noEventSend)  
    if noEventSend == nil or noEventSend == false then
        if g_server ~= nil then
            g_server:broadcastEvent(setlogSplitterEvent.new(vehicle, state), nil, nil, vehicle)
        else 
            g_client:getServerConnection():sendEvent(setlogSplitterEvent.new(vehicle, state))
        end
    end
end