@Override public int hashCode() { int result = user != null ? user.hashCode() : 0; result = 31 * result + dashId; result = 31 * result + reportId; return result; } }
public boolean sendMessageToHardware(short cmd, int msgId, String body) { return sendMessageToHardware(hardwareChannels, cmd, msgId, body); }
public int getAppRequestRate() { return getRequestRate(appChannels); }
private void triggerTimer(SessionDao sessionDao, UserKey userKey, String value, int dashId, int[] deviceIds) { Session session = sessionDao.get(userKey); if (session != null) { if (!session.sendMessageToHardware(dashId, HARDWARE, TIMER_MSG_ID, value, deviceIds)) { actuallySendTimers++; } for (int deviceId : deviceIds) { session.sendToApps(HARDWARE, TIMER_MSG_ID, dashId, deviceId, value); } } }
public boolean sendMessageToHardware(int activeDashId, short cmd, int msgId, String body, int... deviceIds) { return hardwareChannels.size() == 0 || sendMessageToHardware(filter(body.length(), activeDashId, deviceIds), cmd, msgId, body); }
public void sendToApps(short cmd, int msgId, int dashId, int deviceId, String body) { if (isAppConnected()) { String finalBody = prependDashIdAndDeviceId(dashId, deviceId, body); sendToApps(cmd, msgId, dashId, finalBody); } }
public boolean isSameEventLoop(ChannelHandlerContext ctx) { return isSameEventLoop(ctx.channel()); }
private static void completeLogin(Channel channel, Session session, User user, DashBoard dash, Device device, int msgId) { log.debug("completeLogin. {}", channel); session.addHardChannel(channel); channel.writeAndFlush(ACCEPTED); String responseBody = String.valueOf(dash.id) + DEVICE_SEPARATOR + device.id; session.sendToApps(HARDWARE_CONNECTED, msgId, dash.id, responseBody); log.info("{} mqtt hardware joined.", user.email); }
public void sendToSharedApps(Channel sendingChannel, String sharedToken, short cmd, int msgId, String body) { Set<Channel> targetChannels = new HashSet<>(); for (Channel channel : appChannels) { if (channel != sendingChannel && needSync(channel, sharedToken)) { targetChannels.add(channel); } } int channelsNum = targetChannels.size(); if (channelsNum > 0) { send(targetChannels, cmd, msgId, body); } }
public void sendToApps(short cmd, int msgId, int dashId, String finalBody) { Set<Channel> targetChannels = filterByDash(dashId); int targetsNum = targetChannels.size(); if (targetsNum > 0) { send(targetChannels, cmd, msgId, finalBody); } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ReportTaskKey that = (ReportTaskKey) o; if (dashId != that.dashId) { return false; } if (reportId != that.reportId) { return false; } return user != null ? user.equals(that.user) : that.user == null; }
public boolean isUpdated(long lastStart) { return (lastStart <= lastModifiedTs) || isDashUpdated(lastStart); }
private boolean sendMessageToHardware(Set<Channel> targetChannels, short cmd, int msgId, String body) { int channelsNum = targetChannels.size(); if (channelsNum == 0) { return true; // -> no active hardware } send(targetChannels, cmd, msgId, body); return false; // -> there is active hardware }
public void closeHardwareChannelByDashId(UserKey userKey, int dashId) { Session session = userSession.get(userKey); session.closeHardwareChannelByDashId(dashId); }
private static void unlockContent(User user, int reward) { user.addEnergy(reward); log.info("Unlocking content for {}. Reward {}.", user.email, reward); }
public Session getOrCreateSessionByUser(UserKey key, EventLoop initialEventLoop) { Session group = userSession.get(key); //only one side came if (group == null) { Session value = new Session(initialEventLoop); group = userSession.putIfAbsent(key, value); if (group == null) { log.trace("Creating unique session for user: {}", key); return value; } } return group; }
private static void send(Set<Channel> targets, short cmd, int msgId, String body) { StringMessage msg = makeUTF8StringMessage(cmd, msgId, body); sendMessageToMultipleReceivers(targets, msg); }
private void execute(Session session, Profile profile, DashBoard dash, int deviceId, SetPinAction action, long now) { String body = action.makeHardwareBody(); session.sendMessageToHardware(dash.id, HARDWARE, 888, body, deviceId); session.sendToApps(HARDWARE, 888, dash.id, deviceId, body); profile.update(dash, deviceId, action.dataStream.pin, action.dataStream.pinType, action.value, now); }
public boolean sendMessageToHardware(int activeDashId, short cmd, int msgId, String body, int deviceId) { return hardwareChannels.size() == 0 || sendMessageToHardware(filter(body.length(), activeDashId, deviceId), cmd, msgId, body); }
public int getHardRequestRate() { return getRequestRate(hardwareChannels); }