mirror of https://github.com/OpenVidu/openvidu.git
openvidu-java-client: createdAt property
parent
b69fbdac54
commit
41a53c79f8
|
@ -27,6 +27,7 @@ import java.util.Map;
|
||||||
public class Connection {
|
public class Connection {
|
||||||
|
|
||||||
private String connectionId;
|
private String connectionId;
|
||||||
|
private long createdAt;
|
||||||
private OpenViduRole role;
|
private OpenViduRole role;
|
||||||
private String token;
|
private String token;
|
||||||
private String location;
|
private String location;
|
||||||
|
@ -37,9 +38,10 @@ public class Connection {
|
||||||
protected Map<String, Publisher> publishers;
|
protected Map<String, Publisher> publishers;
|
||||||
protected List<String> subscribers;
|
protected List<String> subscribers;
|
||||||
|
|
||||||
protected Connection(String connectionId, OpenViduRole role, String token, String location, String platform, String serverData, String clientData,
|
protected Connection(String connectionId, long createdAt, OpenViduRole role, String token, String location, String platform,
|
||||||
Map<String, Publisher> publishers, List<String> subscribers) {
|
String serverData, String clientData, Map<String, Publisher> publishers, List<String> subscribers) {
|
||||||
this.connectionId = connectionId;
|
this.connectionId = connectionId;
|
||||||
|
this.createdAt = createdAt;
|
||||||
this.role = role;
|
this.role = role;
|
||||||
this.token = token;
|
this.token = token;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
|
@ -59,6 +61,14 @@ public class Connection {
|
||||||
return connectionId;
|
return connectionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timestamp when this connection was established, in UTC milliseconds (ms since
|
||||||
|
* Jan 1, 1970, 00:00:00 UTC)
|
||||||
|
*/
|
||||||
|
public long createdAt() {
|
||||||
|
return this.createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the role of the connection
|
* Returns the role of the connection
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -44,6 +44,7 @@ public class Session {
|
||||||
private static final Logger log = LoggerFactory.getLogger(Session.class);
|
private static final Logger log = LoggerFactory.getLogger(Session.class);
|
||||||
|
|
||||||
private String sessionId;
|
private String sessionId;
|
||||||
|
private long createdAt;
|
||||||
private SessionProperties properties;
|
private SessionProperties properties;
|
||||||
private Map<String, Connection> activeConnections = new ConcurrentHashMap<>();
|
private Map<String, Connection> activeConnections = new ConcurrentHashMap<>();
|
||||||
private boolean recording = false;
|
private boolean recording = false;
|
||||||
|
@ -71,6 +72,14 @@ public class Session {
|
||||||
return this.sessionId;
|
return this.sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timestamp when this session was created, in UTC milliseconds (ms since Jan 1,
|
||||||
|
* 1970, 00:00:00 UTC)
|
||||||
|
*/
|
||||||
|
public long createdAt() {
|
||||||
|
return this.createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a new token associated to Session object with default values for
|
* Gets a new token associated to Session object with default values for
|
||||||
* {@link io.openvidu.java.client.TokenOptions}. This always translates into a
|
* {@link io.openvidu.java.client.TokenOptions}. This always translates into a
|
||||||
|
@ -460,9 +469,10 @@ public class Session {
|
||||||
try {
|
try {
|
||||||
int statusCode = response.getStatusLine().getStatusCode();
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
if ((statusCode == org.apache.http.HttpStatus.SC_OK)) {
|
if ((statusCode == org.apache.http.HttpStatus.SC_OK)) {
|
||||||
String id = (String) httpResponseToJson(response).get("id");
|
JSONObject responseJson = httpResponseToJson(response);
|
||||||
log.info("Returning a SESSIONID: {}", id);
|
this.sessionId = (String) responseJson.get("id");
|
||||||
this.sessionId = id;
|
this.createdAt = (long) responseJson.get("createdAt");
|
||||||
|
log.info("Session '{}' created", this.sessionId);
|
||||||
} else if (statusCode == org.apache.http.HttpStatus.SC_CONFLICT) {
|
} else if (statusCode == org.apache.http.HttpStatus.SC_CONFLICT) {
|
||||||
// 'customSessionId' already existed
|
// 'customSessionId' already existed
|
||||||
this.sessionId = properties.customSessionId();
|
this.sessionId = properties.customSessionId();
|
||||||
|
@ -492,6 +502,7 @@ public class Session {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected Session resetSessionWithJson(JSONObject json) {
|
protected Session resetSessionWithJson(JSONObject json) {
|
||||||
this.sessionId = (String) json.get("sessionId");
|
this.sessionId = (String) json.get("sessionId");
|
||||||
|
this.createdAt = (long) json.get("createdAt");
|
||||||
this.recording = (boolean) json.get("recording");
|
this.recording = (boolean) json.get("recording");
|
||||||
SessionProperties.Builder builder = new SessionProperties.Builder()
|
SessionProperties.Builder builder = new SessionProperties.Builder()
|
||||||
.mediaMode(MediaMode.valueOf((String) json.get("mediaMode")))
|
.mediaMode(MediaMode.valueOf((String) json.get("mediaMode")))
|
||||||
|
@ -528,9 +539,10 @@ public class Session {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.activeConnections.put((String) con.get("connectionId"),
|
this.activeConnections.put((String) con.get("connectionId"),
|
||||||
new Connection((String) con.get("connectionId"), OpenViduRole.valueOf((String) con.get("role")),
|
new Connection((String) con.get("connectionId"), (long) con.get("createdAt"),
|
||||||
(String) con.get("token"), (String) con.get("location"), (String) con.get("platform"),
|
OpenViduRole.valueOf((String) con.get("role")), (String) con.get("token"),
|
||||||
(String) con.get("serverData"), (String) con.get("clientData"), publishers, subscribers));
|
(String) con.get("location"), (String) con.get("platform"), (String) con.get("serverData"),
|
||||||
|
(String) con.get("clientData"), publishers, subscribers));
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -539,6 +551,7 @@ public class Session {
|
||||||
protected String toJson() {
|
protected String toJson() {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("sessionId", this.sessionId);
|
json.put("sessionId", this.sessionId);
|
||||||
|
json.put("createdAt", this.createdAt);
|
||||||
json.put("customSessionId", this.properties.customSessionId());
|
json.put("customSessionId", this.properties.customSessionId());
|
||||||
json.put("recording", this.recording);
|
json.put("recording", this.recording);
|
||||||
json.put("mediaMode", this.properties.mediaMode());
|
json.put("mediaMode", this.properties.mediaMode());
|
||||||
|
|
Loading…
Reference in New Issue