mirror of
https://github.com/ahabhyde/miguelbridge
synced 2025-01-10 06:24:20 +01:00
Added 30 seconds timeout long polling
This commit is contained in:
parent
7b2ce1166c
commit
714c73e1b5
@ -18,9 +18,14 @@ import javax.imageio.ImageIO;
|
||||
public class MatrixBot {
|
||||
//https://matrix.org/docs/guides/client-server.html
|
||||
private final String homeUrl;
|
||||
|
||||
private String accessToken;
|
||||
|
||||
private final int timeoutMs;
|
||||
|
||||
public MatrixBot() throws IOException, FileNotFoundException, ParseException {
|
||||
homeUrl = getHomeServer();
|
||||
timeoutMs = 30 * 1000; //30 seconds
|
||||
}
|
||||
|
||||
public String getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
@ -29,10 +34,6 @@ public class MatrixBot {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
public MatrixBot() throws IOException, FileNotFoundException, ParseException {
|
||||
homeUrl = getHomeServer();
|
||||
}
|
||||
|
||||
public static String readBotUserName() throws FileNotFoundException, IOException, ParseException {
|
||||
FileReader file = new FileReader(Launcher.fileSettings);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
@ -240,7 +241,7 @@ public class MatrixBot {
|
||||
try {
|
||||
String filtro = URLEncoder.encode("{\"room\":{\"timeline\":{\"limit\":1}}}", "UTF-8");
|
||||
String requestUrl = homeUrl +
|
||||
String.format("client/r0/sync?filter=%s&access_token=%s",
|
||||
String.format("client/r0/sync?filter=%s&timeout=" + timeoutMs + "&access_token=%s",
|
||||
filtro, accessToken);
|
||||
|
||||
String[] risposta = RequestHandler.getRequest(requestUrl);
|
||||
|
Loading…
Reference in New Issue
Block a user