CSharpRTMP.Core.Protocols.Rtmp.BaseRTMPAppProtocolHandler.ProcessInvokeConnect C# (CSharp) Method

ProcessInvokeConnect() protected method

protected ProcessInvokeConnect ( BaseRTMPProtocol pFrom, AmfMessage message ) : bool
pFrom BaseRTMPProtocol
message AmfMessage
return bool
        protected virtual bool ProcessInvokeConnect(BaseRTMPProtocol pFrom,AmfMessage message)
        {
            string appName = message.InvokeParam[0][Defines.RM_INVOKE_PARAMS_CONNECT_APP];
            //var parameters = pFrom.CustomParameters;
            //var instanceName = index == -1?"_default_": appName.Substring(index + 1);
            var oldApplication = pFrom.Application;
            var newApp = ClientApplicationManager.SwitchRoom(pFrom, appName, Configuration);

            if (newApp != null && newApp != oldApplication)
            {
                var handler = newApp.GetProtocolHandler<BaseRTMPAppProtocolHandler>(pFrom);
                return handler.ProcessInvokeConnect(pFrom, message);
            }

            if (newApp == null || (newApp == oldApplication && !Application.OnConnect(pFrom, message.InvokeParam)))
            {
                if (!pFrom.SendMessage(ConnectionMessageFactory.GetInvokeConnectError(message, "")))
                {
                    return false;
                }

                if (!pFrom.SendMessage(ConnectionMessageFactory.GetInvokeClose()))
                {
                    return false;
                }
                // pFrom.EnqueueForOutbound();
                return true;
            }
            //1. Send the channel specific messages
            if (!SendRTMPMessage(pFrom, GenericMessageFactory.GetWinAckSize(2500000)))    return false;

            if (!SendRTMPMessage(pFrom, GenericMessageFactory.GetPeerBW(2500000, Defines.RM_PEERBW_TYPE_DYNAMIC))) return false;

            //2. Initialize stream 0
            //if (!SendRTMPMessage(pFrom,  StreamMessageFactory.GetUserControlStreamBegin(0)))
            //{
                
            //    return false;
            //}
            if (!pFrom.SendMessage(GenericMessageFactory.GetChunkSize(pFrom._outboundChunkSize)))  return false;
              
            //3. Send the connect result
            if (!SendRTMPMessage(pFrom, ConnectionMessageFactory.GetInvokeConnectResult(message)))  return false;

            //4. Send onBWDone
            if (!SendRTMPMessage(pFrom, GenericMessageFactory.GetInvokeOnBWDone(1024 * 8))) return false;

            return true;
        }