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 {
|
||||
|
||||
private String connectionId;
|
||||
private long createdAt;
|
||||
private OpenViduRole role;
|
||||
private String token;
|
||||
private String location;
|
||||
|
@ -37,9 +38,10 @@ public class Connection {
|
|||
protected Map<String, Publisher> publishers;
|
||||
protected List<String> subscribers;
|
||||
|
||||
protected Connection(String connectionId, OpenViduRole role, String token, String location, String platform, String serverData, String clientData,
|
||||
Map<String, Publisher> publishers, List<String> subscribers) {
|
||||
protected Connection(String connectionId, long createdAt, OpenViduRole role, String token, String location, String platform,
|
||||
String serverData, String clientData, Map<String, Publisher> publishers, List<String> subscribers) {
|
||||
this.connectionId = connectionId;
|
||||
this.createdAt = createdAt;
|
||||
this.role = role;
|
||||
this.token = token;
|
||||
this.location = location;
|
||||
|
@ -59,6 +61,14 @@ public class Connection {
|
|||
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
|
||||
*/
|
||||
|
|
|
@ -44,6 +44,7 @@ public class Session {
|
|||
private static final Logger log = LoggerFactory.getLogger(Session.class);
|
||||
|
||||
private String sessionId;
|
||||
private long createdAt;
|
||||
private SessionProperties properties;
|
||||
private Map<String, Connection> activeConnections = new ConcurrentHashMap<>();
|
||||
private boolean recording = false;
|
||||
|
@ -71,6 +72,14 @@ public class Session {
|
|||
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
|
||||
* {@link io.openvidu.java.client.TokenOptions}. This always translates into a
|
||||
|
@ -460,9 +469,10 @@ public class Session {
|
|||
try {
|
||||
int statusCode = response.getStatusLine().getStatusCode();
|
||||
if ((statusCode == org.apache.http.HttpStatus.SC_OK)) {
|
||||
String id = (String) httpResponseToJson(response).get("id");
|
||||
log.info("Returning a SESSIONID: {}", id);
|
||||
this.sessionId = id;
|
||||
JSONObject responseJson = httpResponseToJson(response);
|
||||
this.sessionId = (String) responseJson.get("id");
|
||||
this.createdAt = (long) responseJson.get("createdAt");
|
||||
log.info("Session '{}' created", this.sessionId);
|
||||
} else if (statusCode == org.apache.http.HttpStatus.SC_CONFLICT) {
|
||||
// 'customSessionId' already existed
|
||||
this.sessionId = properties.customSessionId();
|
||||
|
@ -492,6 +502,7 @@ public class Session {
|
|||
@SuppressWarnings("unchecked")
|
||||
protected Session resetSessionWithJson(JSONObject json) {
|
||||
this.sessionId = (String) json.get("sessionId");
|
||||
this.createdAt = (long) json.get("createdAt");
|
||||
this.recording = (boolean) json.get("recording");
|
||||
SessionProperties.Builder builder = new SessionProperties.Builder()
|
||||
.mediaMode(MediaMode.valueOf((String) json.get("mediaMode")))
|
||||
|
@ -528,9 +539,10 @@ public class Session {
|
|||
});
|
||||
|
||||
this.activeConnections.put((String) con.get("connectionId"),
|
||||
new Connection((String) con.get("connectionId"), OpenViduRole.valueOf((String) con.get("role")),
|
||||
(String) con.get("token"), (String) con.get("location"), (String) con.get("platform"),
|
||||
(String) con.get("serverData"), (String) con.get("clientData"), publishers, subscribers));
|
||||
new Connection((String) con.get("connectionId"), (long) con.get("createdAt"),
|
||||
OpenViduRole.valueOf((String) con.get("role")), (String) con.get("token"),
|
||||
(String) con.get("location"), (String) con.get("platform"), (String) con.get("serverData"),
|
||||
(String) con.get("clientData"), publishers, subscribers));
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
@ -539,6 +551,7 @@ public class Session {
|
|||
protected String toJson() {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("sessionId", this.sessionId);
|
||||
json.put("createdAt", this.createdAt);
|
||||
json.put("customSessionId", this.properties.customSessionId());
|
||||
json.put("recording", this.recording);
|
||||
json.put("mediaMode", this.properties.mediaMode());
|
||||
|
|
Loading…
Reference in New Issue