SetCabEvent = {};
SetCabEvent_mt = Class(SetCabEvent, Event);

InitEventClass(SetCabEvent, "SetCabEvent");

function SetCabEvent:emptyNew()
      local self = Event:new(SetCabEvent_mt);
      self.className="SetCabEvent";
      return self;
end;

function SetCabEvent:new(object, active)
      local self = SetCabEvent:emptyNew()
      self.active = active;
      self.object = object;
      return self;
end;

function SetCabEvent:readStream(streamId, connection)
      local id = streamReadInt32(streamId);
      self.active = streamReadBool(streamId);
      self.object = networkGetObject(id);
      self:run(connection);
 end;

function SetCabEvent:writeStream(streamId, connection)
      streamWriteInt32(streamId, networkGetObjectId(self.object));
      streamWriteBool(streamId, self.active);
end;

function SetCabEvent:run(connection)
      self.object:setCabVisibility(self.active, true);
      if not connection:getIsServer() then
          g_server:broadcastEvent(SetCabEvent:new(self.object, self.active), nil, connection, self.object);
      end;
end;