Fix reading Json in WebSocket
This commit is contained in:
parent
f176f118a3
commit
4999115ca9
3 changed files with 6 additions and 6 deletions
|
@ -1,7 +1,6 @@
|
|||
package dev.peerat.framework;
|
||||
|
||||
import java.net.Socket;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.jose4j.jwt.consumer.InvalidJwtException;
|
||||
|
||||
|
@ -32,7 +31,6 @@ public class Client<U extends User> extends Thread{
|
|||
writer.flush();
|
||||
writer.close();
|
||||
}catch(InvalidJwtException e){
|
||||
// e.printStackTrace();
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
if(context != null && context.getResponseCode() == 0){
|
||||
|
@ -53,7 +51,6 @@ public class Client<U extends User> extends Thread{
|
|||
try{
|
||||
return this.router.getUser(auth);
|
||||
}catch(InvalidJwtException e){
|
||||
e.printStackTrace();
|
||||
try{
|
||||
writer.response(401, router.getDefaultHeaders(type));
|
||||
writer.flush();
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
import java.net.Socket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -19,7 +18,7 @@ import dev.peerat.framework.utils.json.JsonParser;
|
|||
public class HttpReader{
|
||||
|
||||
private static Pattern HEADER_PATTERN = Pattern.compile("^([^:]*):\\s+(.*)$");
|
||||
private static JsonParser JSON_PARSER = new JsonParser();
|
||||
static JsonParser JSON_PARSER = new JsonParser();
|
||||
|
||||
private Socket socket;
|
||||
private InputStream in;
|
||||
|
|
|
@ -2,13 +2,17 @@ package dev.peerat.framework;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import dev.peerat.framework.utils.json.Json;
|
||||
|
||||
public class WebSocketReader extends HttpReader{
|
||||
|
||||
public WebSocketReader(HttpReader origin) throws Exception{
|
||||
super(origin);
|
||||
}
|
||||
|
||||
|
||||
public <J extends Json> J readJson() throws Exception{
|
||||
return JSON_PARSER.parse(readLine());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readLine() throws IOException{
|
||||
|
|
Loading…
Add table
Reference in a new issue