private void HandleOpen(HttpRequest request, HttpResponse response) { Unreferenced.Parameter(request); //Pass a null IPEndPoint, for this connection will create it on demand RtmptConnection connection = new RtmptConnection(this, null, null, null); FluorineRtmpContext.Initialize(connection); /* * HttpSession session = _endpoint.GetMessageBroker().SessionManager.GetHttpSession(HttpContext.Current); * FluorineContext.Current.SetSession(session); * RtmptConnection connection = new RtmptConnection(this, null, session, null, null); * Client client = this.Endpoint.GetMessageBroker().ClientRegistry.GetClient(connection.ConnectionId) as Client; * FluorineContext.Current.SetClient(client); * FluorineContext.Current.SetConnection(connection); * connection.Initialize(client); * //Current object are set notify listeners. * if (session != null && session.IsNew) * session.NotifyCreated(); * if (client != null) * { * client.RegisterSession(session); * client.NotifyCreated(); * } */ _connections[connection.ConnectionId] = connection; // Return connection id to client ReturnMessage(connection.ConnectionId + "\n", response); }
void CurrentDomain_DomainUnload(object sender, EventArgs e) { try { Stop(); } catch (Exception ex) { Unreferenced.Parameter(ex); } }
/// <summary> /// Requests a registered object to unregister. /// </summary> /// <param name="immediate">true to indicate the registered object should unregister from the hosting environment before returning; otherwise, false.</param> public void Stop(bool immediate) { try { Stop(); } catch (Exception ex) { Unreferenced.Parameter(ex); } HostingEnvironment.UnregisterObject(this); }
private ObjectFactory() { lacLocations = TypeHelper.GetLacLocations(); typeCache = new CopyOnWriteDictionary <string, Type>(); typeConstructorCache = new CopyOnWriteDictionary <Type, ConstructorInvoker>(); try { new ReflectionPermission(ReflectionPermissionFlag.MemberAccess).Demand(); new ReflectionPermission(ReflectionPermissionFlag.RestrictedMemberAccess).Demand(); new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); reflectionEmitPermission = true; } catch (Exception ex) { Unreferenced.Parameter(ex); reflectionEmitPermission = false; } }
private ObjectFactory() { _lacLocations = TypeHelper.GetLacLocations(); _typeCache = new CopyOnWriteDictionary <string, Type>(); #if !SILVERLIGHT _typeConstructorCache = new CopyOnWriteDictionary <Type, ConstructorInvoker>(); try { new ReflectionPermission(ReflectionPermissionFlag.MemberAccess).Demand(); new ReflectionPermission(ReflectionPermissionFlag.RestrictedMemberAccess).Demand(); _reflectionEmitPermission = true; } catch (Exception ex) { Unreferenced.Parameter(ex); _reflectionEmitPermission = false; } #endif }
void EndPreRequestHandlerExecute(IAsyncResult ar) { AsyncHandler asyncHandler = ar as AsyncHandler; Unreferenced.Parameter(asyncHandler); }
protected override void OnInvoke(RtmpConnection connection, RtmpChannel channel, RtmpHeader header, Notify invoke) { IServiceCall call = invoke.ServiceCall; if (invoke.EventType == EventType.STREAM_DATA) { #if !SILVERLIGHT if (Log.IsDebugEnabled) { Log.Debug(string.Format("Ignoring stream data notify with header {0}", header)); } #endif return; } if (call.ServiceMethodName == "_result" || call.ServiceMethodName == "_error") { if (call.ServiceMethodName == "_error") { call.Status = Messaging.Rtmp.Service.Call.STATUS_INVOCATION_EXCEPTION; } if (call.ServiceMethodName == "_result") { call.Status = Messaging.Rtmp.Service.Call.STATUS_SUCCESS_RESULT; } //Get the panding call, if any, as HandlePendingCallResult will remove it IPendingServiceCall pendingCall = connection.GetPendingCall(invoke.InvokeId); HandlePendingCallResult(connection, invoke); if (call.IsSuccess && invoke.InvokeId == 1) { // Should keep this as an Object to stay compatible with FMS3 etc IDictionary aso = call.Arguments[0] as IDictionary; if (aso != null) { object clientId = null; if (aso.Contains("clientid")) { clientId = aso["clientid"]; } #if !SILVERLIGHT if (Log.IsDebugEnabled) { Log.Debug(string.Format("Client id: {0}", clientId)); } #endif _netConnection.SetClientId(clientId != null ? clientId.ToString() : null); } } //Notify via NetConnection if no IPendingServiceCallback was defined but the call failed if (call.ServiceMethodName == "_error") { object[] args = call.Arguments; ASObject statusAso = null; if ((args != null) && (args.Length > 0)) { statusAso = args[0] as ASObject; } bool raiseError = false; if (pendingCall != null) { IPendingServiceCallback[] callbacks = pendingCall.GetCallbacks(); if (callbacks == null || callbacks.Length == 0) { raiseError = true; } } else { raiseError = true; } if (raiseError) { if (statusAso != null) { _netConnection.RaiseNetStatus(statusAso); } else { string msg = __Res.GetString(__Res.Invocation_Failed, pendingCall != null ? pendingCall.ServiceMethodName : string.Empty, "Invocation failed"); _netConnection.RaiseNetStatus(msg); } } } return; } bool onStatus = call.ServiceMethodName.Equals("onStatus") || call.ServiceMethodName.Equals("onMetaData") || call.ServiceMethodName.Equals("onPlayStatus"); if (onStatus) { /* * IDictionary aso = call.Arguments[0] as IDictionary; * // Should keep this as an Object to stay compatible with FMS3 etc * object clientId = null; * if( aso.Contains("clientid") ) * clientId = aso["clientid"]; * if (clientId == null) * clientId = header.StreamId; #if !SILVERLIGHT * if (log.IsDebugEnabled) * log.Debug(string.Format("Client id: {0}", clientId)); #endif * if (clientId != null) * { * NetStream stream = _connection.GetStreamById((int)clientId) as NetStream; * if (stream != null) * { * stream.OnStreamEvent(invoke); * } * } */ NetStream stream = _connection.GetStreamById(header.StreamId) as NetStream; if (stream != null) { stream.OnStreamEvent(invoke); } return; } if (call is IPendingServiceCall) { IPendingServiceCall psc = call as IPendingServiceCall; /* * object result = psc.Result; * object result = psc.Result; * if (result is DeferredResult) * { * DeferredResult dr = result as DeferredResult; * dr.InvokeId = invoke.InvokeId; * dr.ServiceCall = psc; * dr.Channel = channel; * connection.RegisterDeferredResult(dr); * } * else * { * Invoke reply = new Invoke(); * reply.ServiceCall = call; * reply.InvokeId = invoke.InvokeId; * channel.Write(reply); * } */ MethodInfo mi = MethodHandler.GetMethod(_netConnection.Client.GetType(), call.ServiceMethodName, call.Arguments, false, false); if (mi != null) { ParameterInfo[] parameterInfos = mi.GetParameters(); object[] args = new object[parameterInfos.Length]; call.Arguments.CopyTo(args, 0); TypeHelper.NarrowValues(args, parameterInfos); try { InvocationHandler invocationHandler = new InvocationHandler(mi); object result = invocationHandler.Invoke(_netConnection.Client, args); if (mi.ReturnType == typeof(void)) { call.Status = Messaging.Rtmp.Service.Call.STATUS_SUCCESS_VOID; } else { call.Status = result == null ? Messaging.Rtmp.Service.Call.STATUS_SUCCESS_NULL : Messaging.Rtmp.Service.Call.STATUS_SUCCESS_RESULT; psc.Result = result; } } catch (Exception exception) { call.Exception = exception; call.Status = Messaging.Rtmp.Service.Call.STATUS_INVOCATION_EXCEPTION; //log.Error("Error while invoking method " + call.ServiceMethodName + " on client", exception); } } else// if (!onStatus) { string msg = __Res.GetString(__Res.Invocation_NoSuitableMethod, call.ServiceMethodName); call.Status = Messaging.Rtmp.Service.Call.STATUS_METHOD_NOT_FOUND; call.Exception = new FluorineException(msg); _netConnection.RaiseNetStatus(call.Exception); //log.Error(msg, call.Exception); } if (call.Status == Messaging.Rtmp.Service.Call.STATUS_SUCCESS_VOID || call.Status == Messaging.Rtmp.Service.Call.STATUS_SUCCESS_NULL) { #if !SILVERLIGHT if (Log.IsDebugEnabled) { Log.Debug("Method does not have return value, do not reply"); } #endif return; } Invoke reply = new Invoke(); reply.ServiceCall = call; reply.InvokeId = invoke.InvokeId; channel.Write(reply); } else { IPendingServiceCall pendingCall = connection.RetrievePendingCall(invoke.InvokeId); Unreferenced.Parameter(pendingCall); } }
public static void Property(object propertyValue) { Unreferenced.Parameter(propertyValue); }
public virtual ClassDefinition GetClassDefinition(object instance) { ValidationUtils.ArgumentNotNull(instance, "instance"); var type = instance.GetType(); var sb = new StringBuilder(); sb.AppendFormat("Creating class definition for typed {0}", type.FullName); sb.Append("{"); var memberNames = new List <string>(); var classMemberList = new List <ClassMember>(); var propertyInfos = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); for (var i = 0; i < propertyInfos.Length; i++) { var propertyInfo = propertyInfos[i]; var name = propertyInfo.Name; if (propertyInfo.GetCustomAttributes(typeof(TransientAttribute), true).Length > 0) { continue; } if (propertyInfo.GetGetMethod() == null || propertyInfo.GetGetMethod().GetParameters().Length > 0) { //The gateway will not be able to access this property var msg = String.Format(Resources.Reflection_PropertyIndexFail, string.Format("{0}.{1}", type.FullName, propertyInfo.Name)); #if !SILVERLIGHT if (log.IsWarnEnabled) { log.Warn(msg); } #endif continue; } if (memberNames.Contains(name)) { continue; } memberNames.Add(name); var bf = BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance; try { var propertyInfoTmp = type.GetProperty(name); Unreferenced.Parameter(propertyInfoTmp); } catch (AmbiguousMatchException) { bf = BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance; } var attributes = propertyInfo.GetCustomAttributes(false); var classMember = new ClassMember(name, bf, propertyInfo.MemberType, attributes); classMemberList.Add(classMember); if (i != 0) { sb.Append(", "); } sb.Append(name); } var fieldInfos = type.GetFields(BindingFlags.Public | BindingFlags.Instance); for (var i = 0; i < fieldInfos.Length; i++) { var fieldInfo = fieldInfos[i]; #if !SILVERLIGHT if (fieldInfo.GetCustomAttributes(typeof(NonSerializedAttribute), true).Length > 0) { continue; } #endif if (fieldInfo.GetCustomAttributes(typeof(TransientAttribute), true).Length > 0) { continue; } var name = fieldInfo.Name; var attributes = fieldInfo.GetCustomAttributes(false); var classMember = new ClassMember(name, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, fieldInfo.MemberType, attributes); classMemberList.Add(classMember); if (i != 0 && propertyInfos.Length > 0) { sb.Append(", "); } sb.Append(name); } var classMembers = classMemberList.ToArray(); var customClassName = type.FullName; customClassName = FluorineConfiguration.Instance.GetCustomClass(customClassName); var classDefinition = new ClassDefinition(customClassName, classMembers, GetIsExternalizable(instance), GetIsDynamic(instance)); return(classDefinition); }