Skip to content

Commit 6c6f2cd

Browse files
committed
Use @action annotation to instead of setAction. Update the tinystruct version to be 1.1.8.
1 parent 35f50c6 commit 6c6f2cd

4 files changed

Lines changed: 16 additions & 17 deletions

File tree

bin/dispatcher

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env sh
22
ROOT="$(pwd)"
3-
VERSION="1.1.7"
3+
VERSION="1.1.8"
44
cd "$(dirname "$0")" || exit
55
cd "../"
66
# Navigate to the root directory

bin/dispatcher.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
@rem ***************************************************************************
1616
@echo off
1717
set "ROOT=%~dp0..\"
18-
set "VERSION=1.1.7"
18+
set "VERSION=1.1.8"
1919
set "classpath=%ROOT%target\classes:%ROOT%lib\*:%ROOT%WEB-INF\lib\*:%ROOT%WEB-INF\classes":%classpath%
2020
@java -cp "%ROOT%target\classes;%ROOT%lib\tinystruct-%VERSION%-jar-with-dependencies.jar;%ROOT%lib\*;%ROOT%WEB-INF\lib\*;%ROOT%WEB-INF\classes;%USERPROFILE%\.m2\repository\org\tinystruct\tinystruct\%VERSION%\tinystruct-%VERSION%-jar-with-dependencies.jar" org.tinystruct.system.Dispatcher %*

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<dependency>
2222
<groupId>org.tinystruct</groupId>
2323
<artifactId>tinystruct</artifactId>
24-
<version>1.1.7</version>
24+
<version>1.1.8</version>
2525
</dependency>
2626
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
2727
<dependency>

src/main/java/custom/application/v1/smalltalk.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.tinystruct.handler.Reforward;
1616
import org.tinystruct.http.*;
1717
import org.tinystruct.system.ApplicationManager;
18+
import org.tinystruct.system.annotation.Action;
1819
import org.tinystruct.system.template.variable.Variable;
1920
import org.tinystruct.system.util.Matrix;
2021
import org.tinystruct.transfer.DistributedMessageQueue;
@@ -44,23 +45,10 @@ public class smalltalk extends DistributedMessageQueue implements SessionListene
4445
public void init() {
4546
super.init();
4647

47-
this.setAction("talk", "index");
48-
this.setAction("talk/join", "join");
49-
this.setAction("talk/start", "start");
50-
this.setAction("talk/save", "save");
51-
this.setAction("talk/update", "update");
52-
this.setAction("talk/upload", "upload");
53-
this.setAction("talk/command", "command");
54-
this.setAction("talk/topic", "topic");
55-
this.setAction("talk/matrix", "matrix");
56-
this.setAction("files", "download");
57-
this.setAction("chat", "chat");
58-
this.commandLines.get("chat").setDescription("Chat with ChatGPT in command-line.");
59-
6048
this.setVariable("message", "");
6149
this.setVariable("topic", "");
6250

63-
// set env with LANG=en_US.UTF-8
51+
// Set env with LANG=en_US.UTF-8
6452
System.setProperty("LANG", "en_US.UTF-8");
6553

6654
SessionManager.getInstance().addListener(this);
@@ -76,6 +64,7 @@ public void init() {
7664
}
7765
}
7866

67+
@Action("talk")
7968
public smalltalk index() {
8069
final Request request = (Request) this.context.getAttribute(HTTP_REQUEST);
8170
final Response response = (Response) this.context.getAttribute(HTTP_RESPONSE);
@@ -122,10 +111,12 @@ public smalltalk index() {
122111
return this;
123112
}
124113

114+
@Action("talk/update")
125115
public String update(String sessionId) throws ApplicationException {
126116
return this.take(sessionId);
127117
}
128118

119+
@Action("talk/matrix")
129120
public String matrix(String meetingCode) throws ApplicationException {
130121
final Request request = (Request) this.context.getAttribute(HTTP_REQUEST);
131122
final Response response = (Response) this.context.getAttribute(HTTP_RESPONSE);
@@ -140,6 +131,7 @@ public String matrix(String meetingCode) throws ApplicationException {
140131
return "";
141132
}
142133

134+
@Action("talk/join")
143135
public Object join(String meetingCode) throws ApplicationException {
144136
if (groups.containsKey(meetingCode)) {
145137
final Request request = (Request) this.context.getAttribute(HTTP_REQUEST);
@@ -156,6 +148,7 @@ public Object join(String meetingCode) throws ApplicationException {
156148
}
157149
}
158150

151+
@Action("talk/start")
159152
public Object start(String name) throws ApplicationException {
160153
final Request request = (Request) this.context.getAttribute(HTTP_REQUEST);
161154
final Response response = (Response) this.context.getAttribute(HTTP_RESPONSE);
@@ -173,6 +166,7 @@ public Object start(String name) throws ApplicationException {
173166
return name;
174167
}
175168

169+
@Action("talk/command")
176170
public String command() {
177171
final Request request = (Request) this.context.getAttribute(HTTP_REQUEST);
178172
final Object meetingCode = request.getSession().getAttribute("meeting_code");
@@ -195,6 +189,7 @@ public String command() {
195189
return "{ \"error\": \"expired\" }";
196190
}
197191

192+
@Action("talk/save")
198193
public String save() {
199194
final Request request = (Request) this.context.getAttribute(HTTP_REQUEST);
200195
final Object meetingCode = request.getSession().getAttribute("meeting_code");
@@ -264,6 +259,7 @@ public void run() {
264259
return "{ \"error\": \"expired\" }";
265260
}
266261

262+
@Action("chat")
267263
public void chat() {
268264
this.cli_mode = true;
269265
if (this.config.get("openai.api_key") == null || this.config.get("openai.api_key").isEmpty()) {
@@ -755,6 +751,7 @@ public String update(String meetingCode, String sessionId) throws ApplicationExc
755751
return "{}";
756752
}
757753

754+
@Action("talk/upload")
758755
public String upload() throws ApplicationException {
759756
final Request request = (Request) this.context.getAttribute(HTTP_REQUEST);
760757
final Object meetingCode = request.getSession().getAttribute("meeting_code");
@@ -845,10 +842,12 @@ public byte[] download(String fileName, boolean encoded) throws ApplicationExcep
845842
return arr;
846843
}
847844

845+
@Action("files")
848846
public byte[] download(String fileName) throws ApplicationException {
849847
return this.download(fileName, true);
850848
}
851849

850+
@Action("talk/topic")
852851
public boolean topic() {
853852
final Request request = (Request) this.context.getAttribute(HTTP_REQUEST);
854853
final Object meeting_code = request.getSession().getAttribute("meeting_code");

0 commit comments

Comments
 (0)