diff --git a/src/com/em/miguelbridge/botmatrix/MatrixBot.java b/src/com/em/miguelbridge/botmatrix/MatrixBot.java index e287253..e98f8ee 100644 --- a/src/com/em/miguelbridge/botmatrix/MatrixBot.java +++ b/src/com/em/miguelbridge/botmatrix/MatrixBot.java @@ -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);