当前位置: 首页>>代码示例>>Java>>正文


Java ICommand类代码示例

本文整理汇总了Java中org.red5.server.net.ICommand的典型用法代码示例。如果您正苦于以下问题:Java ICommand类的具体用法?Java ICommand怎么用?Java ICommand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ICommand类属于org.red5.server.net包,在下文中一共展示了ICommand类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCommand

import org.red5.server.net.ICommand; //导入依赖的package包/类
/**
 * @param command - command to be processed
 */
protected void onCommand(ICommand command) {
	if (!(command instanceof Notify)) {
		return;
	}
	Notify invoke = (Notify)command;
	if (invoke.getType() == IEvent.Type.STREAM_DATA) {
		return;
	}

	String method = invoke.getCall().getServiceMethodName();
	if ("screenSharerAction".equals(method)) {
		Object[] args = invoke.getCall().getArguments();
		if (args != null && args.length > 0) {
			@SuppressWarnings("unchecked")
			Map<String, Object> params = (Map<String, Object>)args[0];
			if (bool(params.get("stopPublishing"))) {
				stopPublishing();
			}
			if (params.containsKey("error")) {
				frame.setStatus("" + params.get("error"));
			}
		}
	}
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:28,代码来源:Core.java

示例2: 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);
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:20,代码来源:RTMPTProtocolEncoder.java

示例3: onCommand

import org.red5.server.net.ICommand; //导入依赖的package包/类
@Override
protected void onCommand(RTMPConnection conn, Channel channel, Header source, ICommand command) {
	super.onCommand(conn, channel, source, command);
	core.onCommand(command);
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:6,代码来源:RTMPTScreenShare.java

示例4: 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());
    }
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:73,代码来源:RTMPProtocolEncoder.java

示例5: 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());
    }
}
 
开发者ID:Red5,项目名称:red5-client,代码行数:67,代码来源:RTMPClientProtocolEncoder.java

示例6: onCommand

import org.red5.server.net.ICommand; //导入依赖的package包/类
/**
 * Command event handler, which current consists of an Invoke or Notify type object.
 * 
 * @param conn
 *            Connection
 * @param channel
 *            Channel
 * @param source
 *            Header
 * @param command
 *            event context
 */
protected abstract void onCommand(RTMPConnection conn, Channel channel, Header source, ICommand command);
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:14,代码来源:BaseRTMPHandler.java


注:本文中的org.red5.server.net.ICommand类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。