forked from j62/ctbrec
Update MFC SessionState from search result
This commit is contained in:
parent
52bbf78e40
commit
1a0cc73ec3
|
@ -407,6 +407,15 @@ public class MyFreeCamsClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessage(WebSocket webSocket, ByteString bytes) {
|
||||||
|
super.onMessage(webSocket, bytes);
|
||||||
|
LOG.debug("msgb: {}", bytes.hex());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return websocket;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateSessionState(SessionState newState) {
|
private void updateSessionState(SessionState newState) {
|
||||||
if (newState.getUid() <= 0) {
|
if (newState.getUid() <= 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -452,15 +461,6 @@ public class MyFreeCamsClient {
|
||||||
model.update(state, getStreamUrl(state));
|
model.update(state, getStreamUrl(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMessage(WebSocket webSocket, ByteString bytes) {
|
|
||||||
super.onMessage(webSocket, bytes);
|
|
||||||
LOG.debug("msgb: {}", bytes.hex());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return websocket;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Message parseMessage(StringBuilder msgBuffer) {
|
private Message parseMessage(StringBuilder msgBuffer) {
|
||||||
int packetLengthBytes = 6;
|
int packetLengthBytes = 6;
|
||||||
if (msgBuffer.length() < packetLengthBytes) {
|
if (msgBuffer.length() < packetLengthBytes) {
|
||||||
|
@ -676,6 +676,15 @@ public class MyFreeCamsClient {
|
||||||
LOG.trace("Search result: {}", msg);
|
LOG.trace("Search result: {}", msg);
|
||||||
if (StringUtil.isNotBlank(msg.getMessage()) && !Objects.equals(msg.getMessage(), q)) {
|
if (StringUtil.isNotBlank(msg.getMessage()) && !Objects.equals(msg.getMessage(), q)) {
|
||||||
JSONObject json = new JSONObject(msg.getMessage());
|
JSONObject json = new JSONObject(msg.getMessage());
|
||||||
|
|
||||||
|
JsonAdapter<SessionState> adapter = moshi.adapter(SessionState.class);
|
||||||
|
try {
|
||||||
|
SessionState sessionState = Objects.requireNonNull(adapter.fromJson(msg.getMessage()));
|
||||||
|
updateSessionState(sessionState);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("Couldn't parse session state message {}", msg, e);
|
||||||
|
}
|
||||||
|
|
||||||
String name = json.getString("nm");
|
String name = json.getString("nm");
|
||||||
MyFreeCamsModel model = mfc.createModel(name);
|
MyFreeCamsModel model = mfc.createModel(name);
|
||||||
model.setUid(json.getInt("uid"));
|
model.setUid(json.getInt("uid"));
|
||||||
|
|
Loading…
Reference in New Issue