use of com.tvd12.dahlia.core.entity.Collection in project dahlia by youngmonkeys.
the class DahliaCoreLoader method loadCollection.
protected void loadCollection(Collection collection, CollectionStorage storage) {
CollectionSetting setting = collection.getSetting();
FieldSetting idSetting = setting.getId();
long recordPosition = collection.getDataSize();
while (storage.hasMoreRecords(recordPosition)) {
Record record = storage.readRecord(recordPosition, idSetting);
if (record != null)
collection.insert(record);
recordPosition = collection.increaseDataSize();
}
}
use of com.tvd12.dahlia.core.entity.Collection in project ezyfox-server by youngmonkeys.
the class EzySimpleServerContextBuilder method newZoneContexts.
protected Collection<EzyZoneContext> newZoneContexts(EzyServerContext parent) {
Collection<EzyZoneContext> contexts = new ArrayList<>();
EzySettings settings = EzyServerContexts.getSettings(parent);
for (Integer zoneId : settings.getZoneIds()) {
EzyZoneSetting zoneSetting = settings.getZoneById(zoneId);
EzySimpleZone zone = new EzySimpleZone();
zone.setSetting(zoneSetting);
EzyUserDelegate userDelegate = newUserDelegate(parent);
EzyZoneUserManager userManager = newZoneUserManager(zoneSetting, userDelegate);
EzyEventControllers eventControllers = newEventControllers(zoneSetting.getEventControllers());
zone.setUserManager(userManager);
zone.setEventControllers(eventControllers);
EzySimpleZoneContext zoneContext = new EzySimpleZoneContext();
zoneContext.setParent(parent);
zoneContext.setZone(zone);
zoneContext.addAppContexts(newAppContexts(zoneContext));
zoneContext.addPluginContexts(newPluginContexts(zoneContext));
zoneContext.init();
contexts.add(zoneContext);
processWithException(((EzyStartable) userManager)::start);
}
return contexts;
}
use of com.tvd12.dahlia.core.entity.Collection in project ezyfox-server by youngmonkeys.
the class EzyPluginSendResponseImpl method execute.
@Override
public void execute(EzyData data, Collection<EzySession> recipients, boolean encrypted, EzyTransportType transportType) {
EzyResponse response = newResponse(data);
serverContext.send(response, recipients, encrypted, transportType);
}
use of com.tvd12.dahlia.core.entity.Collection in project ezyfox-server by youngmonkeys.
the class EzyStreamBytesImpl method execute.
@Override
public void execute(byte[] bytes, Collection<EzySession> recipients, EzyTransportType transportType) {
EzyStreamingApi streamingApi = server.getStreamingApi();
EzySimpleBytesPackage pack = newPackage(bytes, transportType);
pack.addRecipients(recipients);
try {
streamingApi.response(pack);
} catch (Exception e) {
logger.warn("send: {} bytes, to client: {} error", bytes.length, getRecipientsNames(recipients), e);
} finally {
pack.release();
}
}
use of com.tvd12.dahlia.core.entity.Collection in project ezyfox-server by youngmonkeys.
the class EzyAbstractResponseApi method secureResponse.
protected final void secureResponse(EzyPackage pack, boolean immediate) throws Exception {
EzyConstant connectionType = getConnectionType();
Collection<EzySession> recipients = pack.getRecipients(connectionType);
if (recipients.isEmpty()) {
return;
}
byte[] messageContent = dataToMessageContent(pack.getData());
if (immediate) {
for (EzySession session : recipients) {
byte[] bytes = encryptMessageContent(messageContent, session.getSessionKey());
session.sendNow(createPacket(bytes, pack));
}
} else {
for (EzySession session : recipients) {
byte[] bytes = encryptMessageContent(messageContent, session.getSessionKey());
session.send(createPacket(bytes, pack));
}
}
}
Aggregations