本文整理汇总了Java中org.red5.server.net.ICommand.getCall方法的典型用法代码示例。如果您正苦于以下问题:Java ICommand.getCall方法的具体用法?Java ICommand.getCall怎么用?Java ICommand.getCall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.red5.server.net.ICommand
的用法示例。
在下文中一共展示了ICommand.getCall方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeCommand
import org.red5.server.net.ICommand; //导入方法依赖的package包/类
@Override
protected void encodeCommand(IoBuffer out, ICommand command) {
// if we get an InsufficientBW message for the client, we'll reduce the base tolerance and set drop live to true
final IServiceCall call = command.getCall();
if ("onStatus".equals(call.getServiceMethodName()) && call.getArguments().length >= 1) {
Object arg0 = call.getArguments()[0];
if ("NetStream.Play.InsufficientBW".equals(((Status) arg0).getCode())) {
long baseT = getBaseTolerance();
try {
// drop the tolerances by half but not less than 500
setBaseTolerance(Math.max(baseT / 2, 500));
} catch (Exception e) {
log.debug("Problem setting base tolerance: {}", e.getMessage());
}
setDropLiveFuture(true);
}
}
super.encodeCommand(out, command);
}
示例2: encodeCommand
import org.red5.server.net.ICommand; //导入方法依赖的package包/类
/**
* Encode command event and fill given byte buffer.
*
* @param out
* Buffer to fill
* @param command
* Command event
*/
protected void encodeCommand(IoBuffer out, ICommand command) {
// TODO: tidy up here
Output output = new org.red5.io.amf.Output(out);
final IServiceCall call = command.getCall();
final boolean isPending = (call.getStatus() == Call.STATUS_PENDING);
log.debug("Call: {} pending: {}", call, isPending);
if (!isPending) {
log.debug("Call has been executed, send result");
Serializer.serialize(output, call.isSuccess() ? "_result" : "_error");
} else {
log.debug("This is a pending call, send request");
final String action = (call.getServiceName() == null) ? call.getServiceMethodName() : call.getServiceName() + '.' + call.getServiceMethodName();
Serializer.serialize(output, action); // seems right
}
if (command instanceof Invoke) {
Serializer.serialize(output, Integer.valueOf(command.getTransactionId()));
Serializer.serialize(output, command.getConnectionParams());
}
if (call.getServiceName() == null && "connect".equals(call.getServiceMethodName())) {
// response to initial connect, always use AMF0
output = new org.red5.io.amf.Output(out);
} else {
if (Red5.getConnectionLocal().getEncoding() == Encoding.AMF3) {
output = new org.red5.io.amf3.Output(out);
} else {
output = new org.red5.io.amf.Output(out);
}
}
if (!isPending && (command instanceof Invoke)) {
IPendingServiceCall pendingCall = (IPendingServiceCall) call;
if (!call.isSuccess()) {
log.debug("Call was not successful");
StatusObject status = generateErrorResult(StatusCodes.NC_CALL_FAILED, call.getException());
pendingCall.setResult(status);
}
Object res = pendingCall.getResult();
log.debug("Writing result: {}", res);
Serializer.serialize(output, res);
} else {
log.debug("Writing params");
final Object[] args = call.getArguments();
if (args != null) {
for (Object element : args) {
if (element instanceof ByteBuffer) {
// a byte buffer indicates that serialization is already complete, send raw
final ByteBuffer buf = (ByteBuffer) element;
buf.mark();
try {
out.put(buf);
} finally {
buf.reset();
}
} else {
// standard serialize
Serializer.serialize(output, element);
}
}
}
}
if (command.getData() != null) {
out.setAutoExpand(true);
out.put(command.getData());
}
}
示例3: encodeCommand
import org.red5.server.net.ICommand; //导入方法依赖的package包/类
/**
* Encode notification event and fill given byte buffer.
*
* @param out
* Byte buffer to fill
* @param command
* Notification event
*/
@Override
protected void encodeCommand(IoBuffer out, ICommand command) {
log.debug("encodeCommand - command: {}", command);
RTMPConnection conn = (RTMPConnection) Red5.getConnectionLocal();
Output output = new org.red5.io.amf.Output(out);
final IServiceCall call = command.getCall();
final boolean isPending = (call.getStatus() == Call.STATUS_PENDING);
log.debug("Call: {} pending: {}", call, isPending);
if (!isPending) {
log.debug("Call has been executed, send result");
Serializer.serialize(output, call.isSuccess() ? "_result" : "_error");
} else {
log.debug("This is a pending call, send request");
// for request we need to use AMF3 for client mode if the connection is AMF3
if (conn.getEncoding() == Encoding.AMF3) {
output = new org.red5.io.amf3.Output(out);
}
final String action = (call.getServiceName() == null) ? call.getServiceMethodName() : call.getServiceName() + '.' + call.getServiceMethodName();
Serializer.serialize(output, action);
}
if (command instanceof Invoke) {
Serializer.serialize(output, Integer.valueOf(command.getTransactionId()));
Serializer.serialize(output, command.getConnectionParams());
}
if (call.getServiceName() == null && "connect".equals(call.getServiceMethodName())) {
// response to initial connect, always use AMF0
output = new org.red5.io.amf.Output(out);
} else {
if (conn.getEncoding() == Encoding.AMF3) {
output = new org.red5.io.amf3.Output(out);
} else {
output = new org.red5.io.amf.Output(out);
}
}
if (!isPending && (command instanceof Invoke)) {
IPendingServiceCall pendingCall = (IPendingServiceCall) call;
if (!call.isSuccess()) {
log.debug("Call was not successful");
StatusObject status = generateErrorResult(StatusCodes.NC_CALL_FAILED, call.getException());
pendingCall.setResult(status);
}
Object res = pendingCall.getResult();
log.debug("Writing result: {}", res);
Serializer.serialize(output, res);
} else {
log.debug("Writing params");
final Object[] args = call.getArguments();
if (args != null) {
for (Object element : args) {
Serializer.serialize(output, element);
}
}
}
if (command.getData() != null) {
out.setAutoExpand(true);
out.put(command.getData());
}
}