Commit bb23f01d by Eli Ben Baruch

mde - phase 1 .bug fix

parent 681842b6
...@@ -11,19 +11,19 @@ public class OnEventDetails { ...@@ -11,19 +11,19 @@ public class OnEventDetails {
public String getCallBackUrl() { public String getCallBackUrl() {
return callBackUrl; return callBackUrl;
} }
@JsonProperty("app-key") @JsonProperty("appKey")
public String getAppKey() { public String getAppKey() {
return appKey; return appKey;
} }
@JsonProperty("callbackUrl") @JsonProperty("callbackUrl")
private String callBackUrl; private String callBackUrl;
@JsonProperty("app-key") @JsonProperty("appKey")
private String appKey; private String appKey;
@JsonCreator @JsonCreator
public OnEventDetails(@JsonProperty("callbackUrl") String callBackUrl, @JsonProperty("app-key") String appKey) { public OnEventDetails(@JsonProperty("callbackUrl") String callBackUrl, @JsonProperty("appKey") String appKey) {
this.callBackUrl = callBackUrl; this.callBackUrl = callBackUrl;
this.appKey = appKey; this.appKey = appKey;
} }
...@@ -31,4 +31,10 @@ public class OnEventDetails { ...@@ -31,4 +31,10 @@ public class OnEventDetails {
public boolean isValid() { public boolean isValid() {
return callBackUrl!=null; return callBackUrl!=null;
} }
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Details=[url=").append(callBackUrl).append(",appKey=").append(appKey).append("]");
return sb.toString();
}
} }
...@@ -298,7 +298,7 @@ public class WebSocketEventListener implements WebSocketListener { ...@@ -298,7 +298,7 @@ public class WebSocketEventListener implements WebSocketListener {
@Override @Override
public void onPingFrame(WebSocket websocket, WebSocketFrame frame) throws Exception { public void onPingFrame(WebSocket websocket, WebSocketFrame frame) throws Exception {
String str = connectionId + " " +currentDate()+ "ping frame</a> (opcode = 0x9) was received: "+frame.toString(); String str = connectionId + " " +currentDate()+ "ping frame</a> (opcode = 0x9) was received: "+frame.toString();
logging(str, eTraceLevel.eDEBUG,true); // logging(str, eTraceLevel.eDEBUG,true);
setState(websocket.getState()); setState(websocket.getState());
} }
...@@ -359,16 +359,7 @@ public class WebSocketEventListener implements WebSocketListener { ...@@ -359,16 +359,7 @@ public class WebSocketEventListener implements WebSocketListener {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
// String appKey = details.getAppKey();
// StringBuilder sb=new StringBuilder("\{ \"op\"\: \"add\", \"path\"\: \"\\/app-key\"\:, \""+appKey+"\"\}");
// sb.append(appKey);
//// sb.append("\": { "availability": {"value": "unknown", "timestamp": 0, "mde-key": "$id"}}})
// jsonEvent = JsonPatchAction
// sendEvent()
} }
} }
} }
} catch (IOException e1) { } catch (IOException e1) {
...@@ -394,7 +385,7 @@ public class WebSocketEventListener implements WebSocketListener { ...@@ -394,7 +385,7 @@ public class WebSocketEventListener implements WebSocketListener {
logging("sendHttpPost failed to send event with error: "+e, eTraceLevel.eERROR, true); logging("sendHttpPost failed to send event with error: "+e, eTraceLevel.eERROR, true);
return; return;
} }
logging("sendHttpPost event was send successfuly", eTraceLevel.eDEBUG, true); logging("sendHttpPost event was send successfuly to"+callBackUrl, eTraceLevel.eDEBUG, true);
} }
/** /**
......
...@@ -27,6 +27,7 @@ public class WebSocketManager { ...@@ -27,6 +27,7 @@ public class WebSocketManager {
this.defaultHeaders = defaultHeaders; this.defaultHeaders = defaultHeaders;
this.auth2Client = oAuth2Client; this.auth2Client = oAuth2Client;
} }
public boolean isConnected( String connectionId, String uid){ public boolean isConnected( String connectionId, String uid){
...@@ -55,14 +56,17 @@ public class WebSocketManager { ...@@ -55,14 +56,17 @@ public class WebSocketManager {
webSocketConnection.wait(); webSocketConnection.wait();
if (webSocketConnection.getException()!=null) if (webSocketConnection.getException()!=null)
throw webSocketConnection.getException(); throw webSocketConnection.getException();
else else {
webSocketConnections.put(connectionId,webSocketConnection); webSocketConnections.put(connectionId, webSocketConnection);
System.out.println("websocket created successfully: "+ connectionId+" "+ "uid="+uid+" "+ details.toString());
}
} }
} }
else{ else{
webSocketConnection = webSocketConnections.get(connectionId); webSocketConnection = webSocketConnections.get(connectionId);
webSocketConnection.addEventListener(uid,details); webSocketConnection.addEventListener(uid,details);
System.out.println("websocket updated successfully: "+ connectionId+" "+ "uid="+uid+" was added to websocket. "+ details.toString());
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment