當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。