org.red5.server.api.service.IPendingServiceCallback Java Examples
The following examples show how to use
org.red5.server.api.service.IPendingServiceCallback.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseRTMPHandler.java From red5-server-common with Apache License 2.0 | 6 votes |
/** * Handler for pending call result. Dispatches results to all pending call handlers. * * @param conn * Connection * @param invoke * Pending call result event context */ protected void handlePendingCallResult(RTMPConnection conn, Invoke invoke) { final IServiceCall call = invoke.getCall(); final IPendingServiceCall pendingCall = conn.retrievePendingCall(invoke.getTransactionId()); if (pendingCall != null) { // The client sent a response to a previously made call. Object[] args = call.getArguments(); if (args != null && args.length > 0) { // TODO: can a client return multiple results? pendingCall.setResult(args[0]); } Set<IPendingServiceCallback> callbacks = pendingCall.getCallbacks(); if (!callbacks.isEmpty()) { HashSet<IPendingServiceCallback> tmp = new HashSet<>(); tmp.addAll(callbacks); for (IPendingServiceCallback callback : tmp) { try { callback.resultReceived(pendingCall); } catch (Exception e) { log.error("Error while executing callback {}", callback, e); } } } } }
Example #2
Source File: RTMPConnection.java From red5-server-common with Apache License 2.0 | 5 votes |
/** * When the connection has been closed, notify any remaining pending service calls that they have failed because the connection is * broken. Implementors of IPendingServiceCallback may only deduce from this notification that it was not possible to read a result for * this service call. It is possible that (1) the service call was never written to the service, or (2) the service call was written to * the service and although the remote method was invoked, the connection failed before the result could be read, or (3) although the * remote method was invoked on the service, the service implementor detected the failure of the connection and performed only partial * processing. The caller only knows that it cannot be confirmed that the callee has invoked the service call and returned a result. */ public void sendPendingServiceCallsCloseError() { if (pendingCalls != null && !pendingCalls.isEmpty()) { if (log.isDebugEnabled()) { log.debug("Connection calls pending: {}", pendingCalls.size()); } for (IPendingServiceCall call : pendingCalls.values()) { call.setStatus(Call.STATUS_NOT_CONNECTED); for (IPendingServiceCallback callback : call.getCallbacks()) { callback.resultReceived(call); } } } }
Example #3
Source File: RTMPConnection.java From red5-server-common with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ public void invoke(String method, Object[] params, IPendingServiceCallback callback) { IPendingServiceCall call = new PendingCall(method, params); if (callback != null) { call.registerCallback(callback); } invoke(call); }
Example #4
Source File: BaseRTMPClientHandler.java From red5-client with Apache License 2.0 | 5 votes |
/** * Invoke a method on the server and pass parameters. * * @param method * Method * @param params * Method call parameters * @param callback * Callback object */ @Override public void invoke(String method, Object[] params, IPendingServiceCallback callback) { log.debug("invoke method: {} params {} callback {}", new Object[] { method, params, callback }); if (conn != null) { conn.invoke(method, params, callback); } else { log.info("Connection was null"); PendingCall result = new PendingCall(method, params); result.setStatus(Call.STATUS_NOT_CONNECTED); callback.resultReceived(result); } }
Example #5
Source File: BaseRTMPClientHandler.java From red5-client with Apache License 2.0 | 5 votes |
/** * Invoke a method on the server. * * @param method * Method name * @param callback * Callback handler */ @Override public void invoke(String method, IPendingServiceCallback callback) { log.debug("invoke method: {} params {} callback {}", new Object[] { method, callback }); // get it from the conn manager if (conn != null) { conn.invoke(method, callback); } else { log.info("Connection was null"); PendingCall result = new PendingCall(method); result.setStatus(Call.STATUS_NOT_CONNECTED); callback.resultReceived(result); } }
Example #6
Source File: PendingCall.java From red5-server-common with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ public void unregisterCallback(IPendingServiceCallback callback) { callbacks.remove(callback); }
Example #7
Source File: RTMPClientTest.java From red5-client with Apache License 2.0 | 4 votes |
@Test public void test26() throws InterruptedException { client.setStreamEventHandler(new INetStreamEventHandler() { @Override public void onStreamEvent(Notify notify) { log.info("ClientStream.dispachEvent: {}", notify); } }); client.setServiceProvider(new ClientMethodHander()); client.setConnectionClosedHandler(new Runnable() { @Override public void run() { System.out.println("Connection closed"); } }); client.setExceptionHandler(new ClientExceptionHandler() { @Override public void handleException(Throwable throwable) { throwable.printStackTrace(); } }); IPendingServiceCallback connectCallback = new IPendingServiceCallback() { @Override public void resultReceived(IPendingServiceCall call) { log.info("connectCallback"); ObjectMap<?, ?> map = (ObjectMap<?, ?>) call.getResult(); String code = (String) map.get("code"); log.info("Response code: {}", code); if ("NetConnection.Connect.Rejected".equals(code)) { System.out.printf("Rejected: %s\n", map.get("description")); client.disconnect(); } else if ("NetConnection.Connect.Success".equals(code)) { // 1. Wait for onBWDone timer.schedule(new BandwidthStatusTask(), 2000L); } } }; /* * client.connect("localhost", 1935, "live/remote/0586e318-6277-11e3-adc2-22000a1d91fe", new IPendingServiceCallback() { * @Override public void resultReceived(IPendingServiceCall result) { System.out.println("resultReceived: " + result); ObjectMap<?, ?> map = (ObjectMap<?, ?>) result.getResult(); * String code = (String) map.get("code"); System.out.printf("Response code: %s\n", code); if ("NetConnection.Connect.Rejected".equals(code)) { System.out.printf("Rejected: %s\n", * map.get("description")); client.disconnect(); } else if ("NetConnection.Connect.Success".equals(code)) { System.out.println("success: " + result.isSuccess()); ArrayList<Object> * list = new ArrayList<>(); list.add(new Object[] { "fujifilm-x100s-video-test-1080p-full-hd-hdmp4_720.mp4" }); list.add(new Object[] { * "canon-500d-test-video-720-hd-30-fr-hdmp4_720.mp4" }); Object[] params = { "64", "cc-video-processed/", list }; //Object[] params = { "64", "cc-video-processed/" }; * client.invoke("loadPlaylist", params, new IPendingServiceCallback() { * @Override public void resultReceived(IPendingServiceCall result) { System.out.println(result); } }); } } }); */ client.connect("localhost", 1935, "vod", connectCallback); do { try { Thread.sleep(10000); } catch (InterruptedException e) { } } while (!client.conn.isClosed()); log.debug("Client not connected"); timer.cancel(); log.info("Exit"); }
Example #8
Source File: BaseRTMPClientHandler.java From red5-client with Apache License 2.0 | 4 votes |
public SubscribeStreamCallBack(IPendingServiceCallback wrapped) { log.debug("SubscribeStreamCallBack {}", wrapped.getClass().getName()); this.wrapped = wrapped; }
Example #9
Source File: BaseRTMPClientHandler.java From red5-client with Apache License 2.0 | 4 votes |
public DeleteStreamCallBack(IPendingServiceCallback wrapped) { log.debug("DeleteStreamCallBack {}", wrapped.getClass().getName()); this.wrapped = wrapped; }
Example #10
Source File: BaseRTMPClientHandler.java From red5-client with Apache License 2.0 | 4 votes |
public ReleaseStreamCallBack(IPendingServiceCallback wrapped) { log.debug("ReleaseStreamCallBack {}", wrapped.getClass().getName()); this.wrapped = wrapped; }
Example #11
Source File: BaseRTMPClientHandler.java From red5-client with Apache License 2.0 | 4 votes |
public CreateStreamCallBack(IPendingServiceCallback wrapped) { log.debug("CreateStreamCallBack {}", wrapped.getClass().getName()); this.wrapped = wrapped; }
Example #12
Source File: BaseRTMPClientHandler.java From red5-client with Apache License 2.0 | 4 votes |
public void subscribe(IPendingServiceCallback callback, Object[] params) { log.debug("subscribe - callback: {}", callback); IPendingServiceCallback wrapper = new SubscribeStreamCallBack(callback); invoke("FCSubscribe", params, wrapper); }
Example #13
Source File: BaseRTMPClientHandler.java From red5-client with Apache License 2.0 | 4 votes |
public void deleteStream(IPendingServiceCallback callback) { log.debug("deleteStream - callback: {}", callback); IPendingServiceCallback wrapper = new DeleteStreamCallBack(callback); invoke("deleteStream", null, wrapper); }
Example #14
Source File: BaseRTMPClientHandler.java From red5-client with Apache License 2.0 | 4 votes |
public void releaseStream(IPendingServiceCallback callback, Object[] params) { log.debug("releaseStream - callback: {}", callback); IPendingServiceCallback wrapper = new ReleaseStreamCallBack(callback); invoke("releaseStream", params, wrapper); }
Example #15
Source File: BaseRTMPClientHandler.java From red5-client with Apache License 2.0 | 4 votes |
@Override public void createStream(IPendingServiceCallback callback) { log.debug("createStream - callback: {}", callback); IPendingServiceCallback wrapper = new CreateStreamCallBack(callback); invoke("createStream", null, wrapper); }
Example #16
Source File: ClientInvokeEvent.java From red5-server-common with Apache License 2.0 | 4 votes |
/** * @return the callback */ public IPendingServiceCallback getCallback() { return callback; }
Example #17
Source File: ClientInvokeEvent.java From red5-server-common with Apache License 2.0 | 4 votes |
public final static ClientInvokeEvent build(String method, Object[] params, IPendingServiceCallback callback) { ClientInvokeEvent event = new ClientInvokeEvent(method, params, callback); return event; }
Example #18
Source File: ClientInvokeEvent.java From red5-server-common with Apache License 2.0 | 4 votes |
public ClientInvokeEvent(String method, Object[] params, IPendingServiceCallback callback) { super(Type.CLIENT_INVOKE); this.method = method; this.params = params; this.callback = callback; }
Example #19
Source File: RTMPConnection.java From red5-server-common with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ public void invoke(String method, IPendingServiceCallback callback) { invoke(method, null, callback); }
Example #20
Source File: PendingCall.java From red5-server-common with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ public Set<IPendingServiceCallback> getCallbacks() { return callbacks; }
Example #21
Source File: PendingCall.java From red5-server-common with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ public void registerCallback(IPendingServiceCallback callback) { callbacks.add(callback); }
Example #22
Source File: BaseRTMPClientHandler.java From red5-client with Apache License 2.0 | 3 votes |
/** * Connect RTMP client to server's application via given port * * @param server * Server * @param port * Connection port * @param connectionParams * Connection parameters * @param connectCallback * Connection callback * @param connectCallArguments * Arguments for 'connect' call */ @Override public void connect(String server, int port, Map<String, Object> connectionParams, IPendingServiceCallback connectCallback, Object[] connectCallArguments) { log.debug("connect server: {} port {} connect - params: {} callback: {} args: {}", new Object[] { server, port, connectionParams, connectCallback, Arrays.toString(connectCallArguments) }); log.info("{}://{}:{}/{}", new Object[] { protocol, server, port, connectionParams.get("app") }); this.connectionParams = connectionParams; this.connectArguments = connectCallArguments; if (!connectionParams.containsKey("objectEncoding")) { connectionParams.put("objectEncoding", 0); } this.connectCallback = connectCallback; startConnector(server, port); }
Example #23
Source File: BaseRTMPClientHandler.java From red5-client with Apache License 2.0 | 2 votes |
/** * Connect RTMP client to server's application via given port with given connection callback * * @param server * Server * @param port * Connection port * @param application * Application at that server * @param connectCallback * Connection callback */ @Override public void connect(String server, int port, String application, IPendingServiceCallback connectCallback) { log.debug("connect server: {} port {} application {} connectCallback {}", new Object[] { server, port, application, connectCallback }); connect(server, port, makeDefaultConnectionParams(server, port, application), connectCallback); }
Example #24
Source File: BaseRTMPClientHandler.java From red5-client with Apache License 2.0 | 2 votes |
/** * Connect RTMP client to server's application via given port * * @param server * Server * @param port * Connection port * @param connectionParams * Connection parameters * @param connectCallback * Connection callback */ @Override public void connect(String server, int port, Map<String, Object> connectionParams, IPendingServiceCallback connectCallback) { connect(server, port, connectionParams, connectCallback, null); }
Example #25
Source File: IRTMPClient.java From red5-client with Apache License 2.0 | votes |
public void createStream(IPendingServiceCallback callback);
Example #26
Source File: IRTMPClient.java From red5-client with Apache License 2.0 | votes |
public void invoke(String method, Object[] params, IPendingServiceCallback callback);
Example #27
Source File: IRTMPClient.java From red5-client with Apache License 2.0 | votes |
public void invoke(String method, IPendingServiceCallback callback);
Example #28
Source File: IRTMPClient.java From red5-client with Apache License 2.0 | votes |
public void connect(String server, int port, Map<String, Object> connectionParams, IPendingServiceCallback connectCallback, Object[] connectCallArguments);
Example #29
Source File: IRTMPClient.java From red5-client with Apache License 2.0 | votes |
public void connect(String server, int port, Map<String, Object> connectionParams, IPendingServiceCallback connectCallback);
Example #30
Source File: IRTMPClient.java From red5-client with Apache License 2.0 | votes |
public void connect(String server, int port, String application, IPendingServiceCallback connectCallback);