Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c5354d17b | ||
|
|
c98bd1fb9b | ||
|
|
fe525e9483 | ||
|
|
6acea9b140 | ||
|
|
4beb573052 |
@@ -56,3 +56,6 @@ broker/media
|
|||||||
common/target
|
common/target
|
||||||
server/target
|
server/target
|
||||||
sdk/target
|
sdk/target
|
||||||
|
moments/target
|
||||||
|
monitor
|
||||||
|
wildfire_jmeter
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<relativePath>../</relativePath>
|
<relativePath>../</relativePath>
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>0.35</version>
|
<version>0.36</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>moquette-broker</artifactId>
|
<artifactId>moquette-broker</artifactId>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import win.liyufan.im.IMTopic;
|
|||||||
public class GetTokenHandler extends IMHandler<WFCMessage.GetTokenRequest> {
|
public class GetTokenHandler extends IMHandler<WFCMessage.GetTokenRequest> {
|
||||||
@Override
|
@Override
|
||||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.GetTokenRequest request, Qos1PublishHandler.IMCallback callback) {
|
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.GetTokenRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||||
MemorySessionStore.Session session = m_sessionsStore.createUserSession(fromUser, clientID, request.getPlatform());
|
MemorySessionStore.Session session = m_sessionsStore.updateOrCreateUserSession(fromUser, clientID, request.getPlatform());
|
||||||
TokenAuthenticator authenticator = new TokenAuthenticator();
|
TokenAuthenticator authenticator = new TokenAuthenticator();
|
||||||
String strToken = authenticator.generateToken(fromUser);
|
String strToken = authenticator.generateToken(fromUser);
|
||||||
String result = strToken + "|" + session.getSecret() + "|" + session.getDbSecret();
|
String result = strToken + "|" + session.getSecret() + "|" + session.getDbSecret();
|
||||||
|
|||||||
@@ -1039,78 +1039,76 @@ public class DatabaseStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void persistGroupInfo(final WFCMessage.GroupInfo groupInfo) {
|
void persistGroupInfo(final WFCMessage.GroupInfo groupInfo) {
|
||||||
mScheduler.execute(()->{
|
Connection connection = null;
|
||||||
Connection connection = null;
|
PreparedStatement statement = null;
|
||||||
PreparedStatement statement = null;
|
try {
|
||||||
try {
|
connection = DBUtil.getConnection();
|
||||||
connection = DBUtil.getConnection();
|
String sql = "insert into t_group (`_gid`" +
|
||||||
String sql = "insert into t_group (`_gid`" +
|
", `_name`" +
|
||||||
", `_name`" +
|
", `_portrait`" +
|
||||||
", `_portrait`" +
|
", `_owner`" +
|
||||||
", `_owner`" +
|
", `_type`" +
|
||||||
", `_type`" +
|
", `_extra`" +
|
||||||
", `_extra`" +
|
", `_dt`" +
|
||||||
", `_dt`" +
|
", `_member_count`" +
|
||||||
", `_member_count`" +
|
", `_mute`" +
|
||||||
", `_mute`" +
|
", `_join_type`" +
|
||||||
", `_join_type`" +
|
", `_private_chat`" +
|
||||||
", `_private_chat`" +
|
", `_searchable`" +
|
||||||
", `_searchable`" +
|
", `_member_dt`) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||||
", `_member_dt`) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
" ON DUPLICATE KEY UPDATE " +
|
||||||
" ON DUPLICATE KEY UPDATE " +
|
"`_name` = ?," +
|
||||||
"`_name` = ?," +
|
"`_portrait` = ?," +
|
||||||
"`_portrait` = ?," +
|
"`_owner` = ?," +
|
||||||
"`_owner` = ?," +
|
"`_type` = ?," +
|
||||||
"`_type` = ?," +
|
"`_extra` = ?," +
|
||||||
"`_extra` = ?," +
|
"`_dt` = ?," +
|
||||||
"`_dt` = ?," +
|
"`_member_count` = ?," +
|
||||||
"`_member_count` = ?," +
|
"`_mute` = ?" +
|
||||||
"`_mute` = ?" +
|
", `_join_type` = ?" +
|
||||||
", `_join_type` = ?" +
|
", `_private_chat` = ?" +
|
||||||
", `_private_chat` = ?" +
|
", `_searchable` = ?, " +
|
||||||
", `_searchable` = ?, " +
|
"`_member_dt` = ?";
|
||||||
"`_member_dt` = ?";
|
|
||||||
|
|
||||||
|
|
||||||
statement = connection.prepareStatement(sql);
|
statement = connection.prepareStatement(sql);
|
||||||
|
|
||||||
int index = 1;
|
int index = 1;
|
||||||
statement.setString(index++, groupInfo.getTargetId());
|
statement.setString(index++, groupInfo.getTargetId());
|
||||||
statement.setString(index++, groupInfo.getName());
|
statement.setString(index++, groupInfo.getName());
|
||||||
statement.setString(index++, groupInfo.getPortrait());
|
statement.setString(index++, groupInfo.getPortrait());
|
||||||
statement.setString(index++, groupInfo.getOwner());
|
statement.setString(index++, groupInfo.getOwner());
|
||||||
statement.setInt(index++, groupInfo.getType());
|
statement.setInt(index++, groupInfo.getType());
|
||||||
statement.setString(index++, groupInfo.getExtra());
|
statement.setString(index++, groupInfo.getExtra());
|
||||||
statement.setLong(index++, groupInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
statement.setLong(index++, groupInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||||
statement.setInt(index++, groupInfo.getMemberCount());
|
statement.setInt(index++, groupInfo.getMemberCount());
|
||||||
statement.setInt(index++, groupInfo.getMute());
|
statement.setInt(index++, groupInfo.getMute());
|
||||||
statement.setInt(index++, groupInfo.getJoinType());
|
statement.setInt(index++, groupInfo.getJoinType());
|
||||||
statement.setInt(index++, groupInfo.getPrivateChat());
|
statement.setInt(index++, groupInfo.getPrivateChat());
|
||||||
statement.setInt(index++, groupInfo.getSearchable());
|
statement.setInt(index++, groupInfo.getSearchable());
|
||||||
statement.setLong(index++, groupInfo.getMemberUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
statement.setLong(index++, groupInfo.getMemberUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||||
|
|
||||||
statement.setString(index++, groupInfo.getName());
|
statement.setString(index++, groupInfo.getName());
|
||||||
statement.setString(index++, groupInfo.getPortrait());
|
statement.setString(index++, groupInfo.getPortrait());
|
||||||
statement.setString(index++, groupInfo.getOwner());
|
statement.setString(index++, groupInfo.getOwner());
|
||||||
statement.setInt(index++, groupInfo.getType());
|
statement.setInt(index++, groupInfo.getType());
|
||||||
statement.setString(index++, groupInfo.getExtra());
|
statement.setString(index++, groupInfo.getExtra());
|
||||||
statement.setLong(index++, groupInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
statement.setLong(index++, groupInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||||
statement.setInt(index++, groupInfo.getMemberCount());
|
statement.setInt(index++, groupInfo.getMemberCount());
|
||||||
statement.setInt(index++, groupInfo.getMute());
|
statement.setInt(index++, groupInfo.getMute());
|
||||||
statement.setInt(index++, groupInfo.getJoinType());
|
statement.setInt(index++, groupInfo.getJoinType());
|
||||||
statement.setInt(index++, groupInfo.getPrivateChat());
|
statement.setInt(index++, groupInfo.getPrivateChat());
|
||||||
statement.setInt(index++, groupInfo.getSearchable());
|
statement.setInt(index++, groupInfo.getSearchable());
|
||||||
statement.setLong(index++, groupInfo.getMemberUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
statement.setLong(index++, groupInfo.getMemberUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||||
int count = statement.executeUpdate();
|
int count = statement.executeUpdate();
|
||||||
LOG.info("Update rows {}", count);
|
LOG.info("Update rows {}", count);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Utility.printExecption(LOG, e);
|
Utility.printExecption(LOG, e);
|
||||||
} finally {
|
} finally {
|
||||||
DBUtil.closeDB(connection, statement);
|
DBUtil.closeDB(connection, statement);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MemorySessionStore.Session> getUserActivedSessions(String uid) {
|
List<MemorySessionStore.Session> getUserActivedSessions(String uid) {
|
||||||
@@ -1560,39 +1558,37 @@ public class DatabaseStore {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
void updateGroupMemberCountDt(final String groupId, final int count, final long dt) {
|
void updateGroupMemberCountDt(final String groupId, final int count, final long dt) {
|
||||||
mScheduler.execute(()->{
|
Connection connection = null;
|
||||||
Connection connection = null;
|
PreparedStatement statement = null;
|
||||||
PreparedStatement statement = null;
|
try {
|
||||||
try {
|
connection = DBUtil.getConnection();
|
||||||
connection = DBUtil.getConnection();
|
|
||||||
|
|
||||||
String sql ;
|
String sql ;
|
||||||
|
|
||||||
if (count >= 0) {
|
if (count >= 0) {
|
||||||
sql = "update t_group set `_member_count` = ?, `_member_dt` = ? , `_dt` = ? where `_gid` = ?";
|
sql = "update t_group set `_member_count` = ?, `_member_dt` = ? , `_dt` = ? where `_gid` = ?";
|
||||||
} else {
|
} else {
|
||||||
sql = "update t_group set `_member_dt` = ?, `_dt` = ? where `_gid` = ?";
|
sql = "update t_group set `_member_dt` = ?, `_dt` = ? where `_gid` = ?";
|
||||||
}
|
|
||||||
statement = connection.prepareStatement(sql);
|
|
||||||
|
|
||||||
int index = 1;
|
|
||||||
if (count >=0) {
|
|
||||||
statement.setInt(index++, count);
|
|
||||||
}
|
|
||||||
statement.setLong(index++, dt);
|
|
||||||
statement.setLong(index++, dt);
|
|
||||||
statement.setString(index++, groupId);
|
|
||||||
|
|
||||||
int c = statement.executeUpdate();
|
|
||||||
LOG.info("Update rows {}", c);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
Utility.printExecption(LOG, e);
|
|
||||||
} finally {
|
|
||||||
DBUtil.closeDB(connection, statement);
|
|
||||||
}
|
}
|
||||||
});
|
statement = connection.prepareStatement(sql);
|
||||||
|
|
||||||
|
int index = 1;
|
||||||
|
if (count >=0) {
|
||||||
|
statement.setInt(index++, count);
|
||||||
|
}
|
||||||
|
statement.setLong(index++, dt);
|
||||||
|
statement.setLong(index++, dt);
|
||||||
|
statement.setString(index++, groupId);
|
||||||
|
|
||||||
|
int c = statement.executeUpdate();
|
||||||
|
LOG.info("Update rows {}", c);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
Utility.printExecption(LOG, e);
|
||||||
|
} finally {
|
||||||
|
DBUtil.closeDB(connection, statement);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void persistGroupMember(final String groupId, final List<WFCMessage.GroupMember> memberList) {
|
void persistGroupMember(final String groupId, final List<WFCMessage.GroupMember> memberList) {
|
||||||
|
|||||||
@@ -328,15 +328,24 @@ public class MemorySessionStore implements ISessionsStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Session createUserSession(String username, String clientID, int platform) {
|
public Session updateOrCreateUserSession(String username, String clientID, int platform) {
|
||||||
LOG.debug("createUserSession for client <{}>, user <{}>", clientID, username);
|
LOG.debug("createUserSession for client <{}>, user <{}>", clientID, username);
|
||||||
|
|
||||||
|
Session session = sessions.get(clientID);
|
||||||
|
|
||||||
|
if (session != null && !session.username.equals(username)) {
|
||||||
|
if (userSessions.get(username) != null) {
|
||||||
|
userSessions.get(username).remove(clientID);
|
||||||
|
}
|
||||||
|
}
|
||||||
ClientSession clientSession = new ClientSession(clientID, this);
|
ClientSession clientSession = new ClientSession(clientID, this);
|
||||||
Session session = databaseStore.getSession(username, clientID, clientSession);
|
session = databaseStore.getSession(username, clientID, clientSession);
|
||||||
|
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
session = databaseStore.createSession(username, clientID, clientSession, platform);
|
session = databaseStore.createSession(username, clientID, clientSession, platform);
|
||||||
}
|
}
|
||||||
|
sessions.put(clientID, session);
|
||||||
|
|
||||||
|
|
||||||
if (session.getDeleted() > 0) {
|
if (session.getDeleted() > 0) {
|
||||||
session.setDeleted(0);
|
session.setDeleted(0);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public interface ISessionsStore {
|
|||||||
*/
|
*/
|
||||||
boolean contains(String clientID);
|
boolean contains(String clientID);
|
||||||
|
|
||||||
Session createUserSession(String username, String clientID, int platform);
|
Session updateOrCreateUserSession(String username, String clientID, int platform);
|
||||||
|
|
||||||
ErrorCode loadActiveSession(String username, String clientID);
|
ErrorCode loadActiveSession(String username, String clientID);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>0.35</version>
|
<version>0.36</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<!--<relativePath>../pom.xml</relativePath>-->
|
<!--<relativePath>../pom.xml</relativePath>-->
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>0.35</version>
|
<version>0.36</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>distribution</artifactId>
|
<artifactId>distribution</artifactId>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
|
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>0.35</version>
|
<version>0.36</version>
|
||||||
<name>Wildfire Chat</name>
|
<name>Wildfire Chat</name>
|
||||||
<description>Wildfire Chat Server</description>
|
<description>Wildfire Chat Server</description>
|
||||||
<inceptionYear>2019</inceptionYear>
|
<inceptionYear>2019</inceptionYear>
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>wildfirechat-parent</artifactId>
|
<artifactId>wildfirechat-parent</artifactId>
|
||||||
<groupId>cn.wildfirechat</groupId>
|
<groupId>cn.wildfirechat</groupId>
|
||||||
<version>0.35</version>
|
<version>0.36</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user