Inheritance: IDisposable
Esempio n. 1
0
        public AMFObjectWriter WriteAMFResponse(string name, string code, string description)
        {
            var message = CreateBufferedMessage();

            WriteResponseHeader(message.Writer, name, CallbackHandle);
            var entireCode = Obj;

            if (!string.IsNullOrEmpty(code))
            {
                entireCode += "." + code;
                this.Log().Info(entireCode);
            }
            var precValue = message.Writer.AMF0Preference;

            message.Writer.AMF0Preference = true;
            var writer = new AMFObjectWriter(message.Writer)
            {
                ["level"] = name == "_error" ? "error" : "status",
                ["code"]  = entireCode
            };

            if (!string.IsNullOrEmpty(description))
            {
                writer["description"] = description;
            }
            message.Writer.AMF0Preference = precValue;
            return(writer);
        }
Esempio n. 2
0
        public void Connect(Variant connectArgs, Action <Flow, Variant> callback)
        {
            AMF0Writer request   = WriteAMFRequestMessage("connect", Band.PushCallBack(callback));
            var        amfwriter = new AMFObjectWriter(request, connectArgs);

            amfwriter.Dispose();
            Flush(true);
        }
Esempio n. 3
0
 public bool OnConnection(Variant parameters, Session session, AMFObjectWriter response)
 {
     if (!Connected)
     {
         Connected = Handler.OnConnection(session, parameters, response);
         if (Connected)
         {
             Handler.Peers.Add(IdStr, this);
         }
     }
     else
     {
         Logger.FATAL("Client {0} seems already connected!", Id);
     }
     return(Connected);
 }
Esempio n. 4
0
        public override bool OnConnection(Session session, Variant parameters, AMFObjectWriter response)
        {
            string appName = parameters[0][Defines.RM_INVOKE_PARAMS_CONNECT_APP];
            //var parameters = pFrom.CustomParameters;
            //var instanceName = index == -1?"_default_": appName.Substring(index + 1);
            var oldApplication = Application;
            var newApp         = ClientApplicationManager.SwitchRoom(this, appName, Application.Configuration);

            if (newApp != null && newApp != oldApplication)
            {
                var handler = newApp.GetProtocolHandler <BaseRtmfpAppProtocolHandler>(this);
                return(handler.CurrentProtocol.OnConnection(session, parameters, response));
            }

            if (newApp == null || (newApp == oldApplication && !Application.OnConnect(session, parameters)))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 5
0
 public void Connect(Variant connectArgs, Action<Flow,Variant> callback)
 {
     AMF0Writer request = WriteAMFRequestMessage("connect", Band.PushCallBack(callback));
     var amfwriter = new AMFObjectWriter(request, connectArgs);
     amfwriter.Dispose();
     Flush(true);
 }
Esempio n. 6
0
 public AMFObjectWriter WriteAMFResponse(string name, string code, string description)
 {
     var message = CreateBufferedMessage();
     WriteResponseHeader(message.Writer,name,CallbackHandle);
     var entireCode = Obj;
     if (!string.IsNullOrEmpty(code))
     {
         entireCode += "." + code;
         this.Log().Info(entireCode);
     }
     var precValue = message.Writer.AMF0Preference;
     message.Writer.AMF0Preference = true;
     var writer = new AMFObjectWriter(message.Writer)
     {
         ["level"] = name == "_error" ? "error" : "status",
         ["code"] = entireCode
     };
     if (!string.IsNullOrEmpty(description)) writer["description"] = description;
     message.Writer.AMF0Preference = precValue;
     return writer;
 }
Esempio n. 7
0
 public virtual bool OnConnection(Session session, Variant parameters, AMFObjectWriter response)
 {
     //throw new NotImplementedException();
     return true;
 }
        public override bool OnConnection(Session session, Variant parameters, AMFObjectWriter response)
        {
            string appName = parameters[0][Defines.RM_INVOKE_PARAMS_CONNECT_APP];
            //var parameters = pFrom.CustomParameters;
            //var instanceName = index == -1?"_default_": appName.Substring(index + 1);
            var oldApplication = Application;
            var newApp = ClientApplicationManager.SwitchRoom(this, appName, Application.Configuration);

            if (newApp != null && newApp != oldApplication)
            {
                var handler = newApp.GetProtocolHandler<BaseRtmfpAppProtocolHandler>(this);
                return handler.CurrentProtocol.OnConnection(session, parameters, response);
            }

            if (newApp == null || (newApp == oldApplication && !Application.OnConnect(session, parameters)))
            {
                return false;
            }

            return true;
        }
 public virtual bool OnConnection(Session session, Variant parameters, AMFObjectWriter response)
 {
     //throw new NotImplementedException();
     return(true);
 }