本文整理汇总了Java中org.red5.server.api.IConnection.hasAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java IConnection.hasAttribute方法的具体用法?Java IConnection.hasAttribute怎么用?Java IConnection.hasAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.red5.server.api.IConnection
的用法示例。
在下文中一共展示了IConnection.hasAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appDisconnect
import org.red5.server.api.IConnection; //导入方法依赖的package包/类
@Override
public void appDisconnect(IConnection conn)
{
String username;
String roomname;
try
{
if(conn.hasAttribute("username")){
username = conn.getStringAttribute("username");
roomname = conn.getStringAttribute("roomname");
this.removeUser(username, roomname);
}
}
catch(Exception e)
{
log.error("Error removing user : ", e);
}
super.appDisconnect(conn);
}
示例2: generateFilename
import org.red5.server.api.IConnection; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public String generateFilename(IScope scope, String name, String extension, GenerationType type) {
logger.debug("Get stream directory: scope={}, name={}, type={}", new Object[]{scope, name, type.toString()});
StringBuilder path = new StringBuilder();
// get the session id
IConnection conn = Red5.getConnectionLocal();
if (conn.hasAttribute("sessionId")) {
String sessionId = conn.getStringAttribute("sessionId");
path.append(sessionId);
path.append('/');
}
// add resources name
path.append(name);
// add extension if we have one
if (extension != null){
// add extension
path.append(extension);
}
// determine whether its playback or record
if (type.equals(GenerationType.PLAYBACK)) {
logger.debug("Playback path used");
// look on s3 for the file first
boolean found = false;
try {
S3Service s3Service = new RestS3Service(awsCredentials);
S3Bucket bucket = s3Service.getBucket(bucketName);
String objectKey = path.toString();
S3Object file = s3Service.getObject(bucket, objectKey);
if (file != null) {
S3Object details = s3Service.getObjectDetails(bucket, objectKey);
logger.debug("Details - key: {} content type: {}", details.getKey(), details.getContentType());
path.insert(0, bucket.getLocation());
// set found flag
found = true;
}
} catch (S3ServiceException e) {
logger.warn("Error looking up media file", e);
}
// use local path
if (!found) {
logger.debug("File was not found on S3, using local playback location");
path.insert(0, playbackPath);
}
} else {
logger.debug("Record path used");
path.insert(0, recordPath);
}
String fileName = path.toString();
logger.debug("Generated filename: {}", fileName);
return fileName;
}