Skip to content

Commit

Permalink
publish on change current session and synchronized
Browse files Browse the repository at this point in the history
  • Loading branch information
supertick committed Mar 21, 2024
1 parent 9e3e6d2 commit a94466b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/myrobotlab/programab/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private synchronized Chat getChat() {
return chat;
}

public void savePredicates() {
synchronized public void savePredicates() {
StringBuilder sb = new StringBuilder();
TreeSet<String> sort = new TreeSet<>();
sort.addAll(getChat().predicates.keySet());
Expand All @@ -122,7 +122,7 @@ public void savePredicates() {
* Get all current predicate names and values
* @return
*/
public Map<String, String> getPredicates() {
synchronized public Map<String, String> getPredicates() {
TreeMap<String, String> sort = new TreeMap<>();
// copy keys, making this sort thread safe
Set<String> keys = new HashSet(getChat().predicates.keySet());
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/myrobotlab/service/ProgramAB.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,15 @@ public Response getResponse(String userName, String botName, String text, boolea
// update the current session if we want to change which bot is at
// attention.
if (updateCurrentSession) {

boolean sessionChanged = (!userName.equals(config.currentUserName) || !botName.equals(config.currentBotName));

setCurrentUserName(userName);
setCurrentBotName(botName);

if (sessionChanged) {
invoke("publishSession", getSessionKey(userName, botName));
}
}

// Get the actual bots aiml based response for this session
Expand Down

0 comments on commit a94466b

Please sign in to comment.