/**
  * Invoke a method on the server and pass parameters.
  *
  * @param method Method
  * @param params Method call parameters
  * @param callback Callback object
  */
 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);
   }
 }
 /** {@inheritDoc} */
 @Override
 public void connectionOpened(RTMPConnection conn) {
   log.trace("connectionOpened - conn: {}", conn);
   // Send "connect" call to the server
   Channel channel = conn.getChannel((byte) 3);
   PendingCall pendingCall = new PendingCall("connect");
   pendingCall.setArguments(connectArguments);
   Invoke invoke = new Invoke(pendingCall);
   invoke.setConnectionParams(connectionParams);
   invoke.setTransactionId(1);
   if (connectCallback != null) {
     pendingCall.registerCallback(connectCallback);
   }
   conn.registerPendingCall(invoke.getTransactionId(), pendingCall);
   log.debug("Writing 'connect' invoke: {}, invokeId: {}", invoke, invoke.getTransactionId());
   channel.write(invoke);
 }