use of com.akaxin.site.storage.bean.GroupMessageBean in project openzaly by akaxincom.
the class SQLiteGroupMessageDao method queryGroupMessage.
/**
* 查询的结果,排除发送者的deviceId
*
* @param groupId
* @param userId
* @param deviceId
* @param start
* @return
* @throws SQLException
*/
public List<GroupMessageBean> queryGroupMessage(String groupId, String userId, String deviceId, long start, int limit) throws SQLException {
long startTime = System.currentTimeMillis();
List<GroupMessageBean> gmsgList = new ArrayList<GroupMessageBean>();
String sql = "SELECT a.id,a.site_group_id,a.msg_id,a.send_user_id,a.send_device_id,a.msg_type,a.content,a.msg_time FROM " + GROUP_MESSAGE_TABLE + " AS a LEFT JOIN site_group_profile AS b WHERE a.site_group_id=b.site_group_id AND a.site_group_id=? AND a.id>? AND b.group_status=1 AND a.send_device_id IS NOT ? LIMIT ?;";
start = queryGroupPointer(groupId, userId, deviceId, start);
if (start == 0) {
start = queryMaxGroupPointerWithUser(groupId, userId) - 10;
}
PreparedStatement statement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
statement.setString(1, groupId);
statement.setLong(2, start);
statement.setString(3, deviceId);
statement.setInt(4, limit);
ResultSet rs = statement.executeQuery();
while (rs.next()) {
GroupMessageBean gmsgBean = new GroupMessageBean();
gmsgBean.setId(rs.getInt(1));
gmsgBean.setSiteGroupId(rs.getString(2));
gmsgBean.setMsgId(rs.getString(3));
gmsgBean.setSendUserId(rs.getString(4));
gmsgBean.setSendDeviceId(rs.getString(5));
gmsgBean.setMsgType(rs.getInt(6));
gmsgBean.setContent(rs.getString(7));
gmsgBean.setMsgTime(rs.getLong(8));
gmsgList.add(gmsgBean);
}
LogUtils.dbDebugLog(logger, startTime, gmsgList.size(), sql, groupId, start, deviceId, limit);
return gmsgList;
}
use of com.akaxin.site.storage.bean.GroupMessageBean in project openzaly by akaxincom.
the class SyncGroupMessageHandler method handle.
public Boolean handle(Command command) {
ChannelSession channelSession = command.getChannelSession();
try {
ImSyncMessageProto.ImSyncMessageRequest syncRequest = ImSyncMessageProto.ImSyncMessageRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
String deviceId = command.getDeviceId();
Map<String, Long> groupPointerMap = syncRequest.getGroupsPointerMap();
LogUtils.requestDebugLog(logger, command, syncRequest.toString());
int syncTotalCount = 0;
// 查找个人有多少群
List<String> userGroups = userGroupDao.getUserGroupsId(siteUserId);
if (userGroups != null) {
for (String groupId : userGroups) {
long clientGroupPointer = 0;
if (groupPointerMap != null && groupPointerMap.get(groupId) != null) {
clientGroupPointer = groupPointerMap.get(groupId);
}
// 校验群消息游标
long maxGroupMessagePointer = syncDao.queryGroupMessagePointer(groupId, siteUserId, deviceId);
long startPointer = NumUtils.getMax(maxGroupMessagePointer, clientGroupPointer);
while (true) {
List<GroupMessageBean> msgList = syncDao.queryGroupMessage(groupId, siteUserId, deviceId, startPointer, SYNC_MAX_MESSAGE_COUNT);
if (msgList != null && msgList.size() > 0) {
startPointer = groupMessageToClient(channelSession.getChannel(), siteUserId, msgList);
syncTotalCount += msgList.size();
}
if (msgList == null || msgList.size() < SYNC_MAX_MESSAGE_COUNT) {
break;
}
}
}
}
logger.debug("client={} siteUserId={} deviceId={} sync group-msg count={}", command.getClientIp(), siteUserId, deviceId, syncTotalCount);
msgFinishToClient(channelSession.getChannel(), siteUserId, deviceId);
} catch (Exception e) {
logger.error("sync group message error.command=" + command, e);
}
return true;
}
use of com.akaxin.site.storage.bean.GroupMessageBean in project openzaly by akaxincom.
the class GroupMessageImageHandler method handle.
public Boolean handle(Command command) {
ChannelSession channelSession = command.getChannelSession();
try {
ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.parseFrom(command.getParams());
int type = request.getType().getNumber();
if (CoreProto.MsgType.GROUP_IMAGE_VALUE == type) {
String siteUserId = command.getSiteUserId();
String deviceId = command.getDeviceId();
String gmsgId = request.getGroupImage().getMsgId();
String groupId = request.getGroupImage().getSiteGroupId();
String groupImageId = request.getGroupImage().getImageId();
long msgTime = System.currentTimeMillis();
GroupMessageBean gmsgBean = new GroupMessageBean();
gmsgBean.setMsgId(gmsgId);
gmsgBean.setSendUserId(siteUserId);
gmsgBean.setSendDeviceId(deviceId);
gmsgBean.setSiteGroupId(groupId);
gmsgBean.setContent(groupImageId);
gmsgBean.setMsgType(type);
gmsgBean.setMsgTime(msgTime);
LogUtils.requestDebugLog(logger, command, gmsgBean.toString());
boolean success = messageDao.saveGroupMessage(gmsgBean);
msgStatusResponse(command, gmsgId, msgTime, success);
return success;
}
return true;
} catch (Exception e) {
LogUtils.requestErrorLog(logger, command, this.getClass(), e);
}
return false;
}
use of com.akaxin.site.storage.bean.GroupMessageBean in project openzaly by akaxincom.
the class GroupMessageImageSecretHandler method handle.
public Boolean handle(Command command) {
ChannelSession channelSession = command.getChannelSession();
try {
ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.parseFrom(command.getParams());
int type = request.getType().getNumber();
if (CoreProto.MsgType.GROUP_SECRET_TEXT_VALUE == type) {
String siteUserId = command.getSiteUserId();
String deviceId = command.getDeviceId();
// String group_user_id = request.getGroupSecretText().getSiteUserId();
String gmsg_id = request.getGroupSecretText().getMsgId();
String group_id = request.getGroupSecretText().getSiteGroupId();
String group_text = request.getGroupSecretText().getText().toStringUtf8();
command.setSiteGroupId(group_id);
// command.setField("group_id", group_id);
System.out.println("GroupMsg = id=" + gmsg_id + "," + siteUserId + "," + group_id + "," + group_text + ",");
long msgTime = System.currentTimeMillis();
GroupMessageBean gmsgBean = new GroupMessageBean();
gmsgBean.setSendDeviceId(deviceId);
gmsgBean.setMsgTime(msgTime);
messageDao.saveGroupMessage(gmsgBean);
msgResponse(channelSession.getChannel(), command, siteUserId, group_id, gmsg_id, msgTime);
return true;
}
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
use of com.akaxin.site.storage.bean.GroupMessageBean in project openzaly by akaxincom.
the class GroupMessageTextHandler method handle.
public Boolean handle(Command command) {
ChannelSession channelSession = command.getChannelSession();
try {
ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.parseFrom(command.getParams());
int type = request.getType().getNumber();
if (CoreProto.MsgType.GROUP_TEXT_VALUE == type) {
String siteUserId = command.getSiteUserId();
String deviceId = command.getDeviceId();
String gmsgId = request.getGroupText().getMsgId();
String groupId = request.getGroupText().getSiteGroupId();
String groupText = request.getGroupText().getText().toStringUtf8();
long msgTime = System.currentTimeMillis();
GroupMessageBean gmsgBean = new GroupMessageBean();
gmsgBean.setMsgId(gmsgId);
gmsgBean.setSendUserId(siteUserId);
gmsgBean.setSendDeviceId(deviceId);
gmsgBean.setSiteGroupId(groupId);
gmsgBean.setContent(groupText);
gmsgBean.setMsgType(type);
gmsgBean.setMsgTime(msgTime);
LogUtils.requestDebugLog(logger, command, gmsgBean.toString());
boolean success = messageDao.saveGroupMessage(gmsgBean);
msgStatusResponse(command, gmsgId, msgTime, success);
return success;
}
return true;
} catch (Exception e) {
LogUtils.requestErrorLog(logger, command, this.getClass(), e);
}
return false;
}
Aggregations