예제 #1
0
        internal void InternalInvokeAsync(IMessageSink ar, Message reqMsg, bool useDispatchMessage, int callType)
        {
            Identity         identityObject  = this.IdentityObject;
            ServerIdentity   serverIdentity  = identityObject as ServerIdentity;
            MethodCall       methodCall      = new MethodCall((IMessage)reqMsg);
            IInternalMessage internalMessage = (IInternalMessage)methodCall;

            internalMessage.IdentityObject = identityObject;
            if (serverIdentity != null)
            {
                internalMessage.ServerIdentityObject = serverIdentity;
            }
            if (useDispatchMessage)
            {
                ChannelServices.AsyncDispatchMessage((IMessage)methodCall, (callType & 8) != 0 ? (IMessageSink)null : ar);
            }
            else
            {
                if (identityObject.EnvoyChain == null)
                {
                    throw new InvalidOperationException(Environment.GetResourceString("Remoting_Proxy_InvalidState"));
                }
                identityObject.EnvoyChain.AsyncProcessMessage((IMessage)methodCall, (callType & 8) != 0 ? (IMessageSink)null : ar);
            }
            if ((callType & 1) == 0 || (callType & 8) == 0)
            {
                return;
            }
            ar.SyncProcessMessage((IMessage)null);
        }
예제 #2
0
        private object[] WriteMethodCall(IMethodCallMessage mcm)
        {
            string uri             = mcm.Uri;
            string methodName      = mcm.MethodName;
            string typeName        = mcm.TypeName;
            object methodSignature = (object)null;

            object[] properties = (object[])null;
            Type[]   instArgs   = (Type[])null;
            if (mcm.MethodBase.IsGenericMethod)
            {
                instArgs = mcm.MethodBase.GetGenericArguments();
            }
            object[]         args            = mcm.Args;
            IInternalMessage internalMessage = mcm as IInternalMessage;

            if (internalMessage == null || internalMessage.HasProperties())
            {
                properties = ObjectWriter.StoreUserPropertiesForMethodMessage((IMethodMessage)mcm);
            }
            if (mcm.MethodSignature != null && RemotingServices.IsMethodOverloaded((IMethodMessage)mcm))
            {
                methodSignature = mcm.MethodSignature;
            }
            LogicalCallContext logicalCallContext = mcm.LogicalCallContext;
            object             callContext        = logicalCallContext != null ? (!logicalCallContext.HasInfo ? (object)logicalCallContext.RemotingData.LogicalCallID : (object)logicalCallContext) : (object)null;

            return(this.serWriter.WriteCallArray(uri, methodName, typeName, instArgs, args, methodSignature, callContext, properties));
        }
예제 #3
0
    protected override void Beat()
    {
        IInternalMessage message = SystemMessageQueue.Instance.Poll();

        if (message != null)
        {
            switch (message.GetMessageId())
            {
            case AsyncTaskMessage.ASYNC_MESSAGE_ID:
            {
                AsyncTaskMessage asyncTaskMessage = message as AsyncTaskMessage;
                AsyncState       state            = asyncTaskMessage.State;
                IAsyncTask       asyncTask        = asyncTaskMessage.AsyncTask;
                if (state == AsyncState.DoAsync)
                {
                    throw new ApplicationException(string.Format("asyncTask:{0} [DoAsyncTask] infinite loop.", asyncTask.GetType().FullName));
                }
                AsyncManager.Instance.ExecuteAsyncTask(state, asyncTask);
                break;
            }

            default:
            {
                break;
            }
            }
        }
    }
예제 #4
0
 /// <summary>
 /// 将一个系统消息加入到队列中
 /// </summary>
 /// <param name="internalMessage">系统消息对象</param>
 public void Offer(IInternalMessage internalMessage)
 {
     lock (this)
     {
         messageQueue.Enqueue(internalMessage);
     }
 }
예제 #5
0
        // This check if the call-site on the TP is in our own AD
        // It also handles the special case where the TP is on
        // a well-known object and we cannot do stack-blting
        internal bool IsOKToStackBlt(IMethodMessage mcMsg, Object server)
        {
            bool    bOK = false;
            Message msg = mcMsg as Message;

            if (null != msg)
            {
                IInternalMessage iiMsg = (IInternalMessage)msg;

                // If there is a frame in the message we can always
                // Blt it (provided it is not a proxy to a well-known
                // object in our own appDomain)!
                // The GetThisPtr == server test allows for people to wrap
                // our proxy with their own interception .. in that case
                // we should not blt the stack.
                if (msg.GetFramePtr() != IntPtr.Zero &&
                    msg.GetThisPtr() == server
                    &&
                    (iiMsg.IdentityObject == null ||
                     (iiMsg.IdentityObject != null &&
                      iiMsg.IdentityObject == iiMsg.ServerIdentityObject
                     )
                    )
                    )
                {
                    bOK = true;
                }
            }

            return(bOK);
        }
예제 #6
0
        // This is called from InternalInvoke above when someone makes an
        // Async (or a one way) call on a TP
        internal void InternalInvokeAsync(IMessageSink ar, Message reqMsg,
                                          bool useDispatchMessage, int callType)
        {
            IMessageCtrl     cc       = null;
            Identity         idObj    = IdentityObject;
            ServerIdentity   serverID = idObj as ServerIdentity;
            MethodCall       cpyMsg   = new MethodCall(reqMsg);
            IInternalMessage iim      = ((IInternalMessage)cpyMsg);

            // Set the identity in the message object
            iim.IdentityObject = idObj;
            if (null != serverID)
            {
                Message.DebugOut("Setting SrvID on deser msg\n");
                iim.ServerIdentityObject = serverID;
            }

            if (useDispatchMessage)
            {
                Message.DebugOut(
                    "RemotingProxy.Invoke: Calling AsyncDispatchMessage\n");

                BCLDebug.Assert(ar != null, "ar != null");
                BCLDebug.Assert((callType & Message.BeginAsync) != 0,
                                "BeginAsync flag not set!");

                Message.DebugOut("Calling AsynDispatchMessage \n");
                cc = ChannelServices.AsyncDispatchMessage(
                    cpyMsg,
                    ((callType & Message.OneWay) != 0)
                                        ? null : ar);
            }
            else if (null != idObj.EnvoyChain)
            {
                Message.DebugOut("RemotingProxy.Invoke: Calling AsyncProcessMsg on the envoy chain\n");

                cc = idObj.EnvoyChain.AsyncProcessMessage(
                    cpyMsg,
                    ((callType & Message.OneWay) != 0)
                                        ? null : ar);
            }
            else
            {
                // Channel sink cannot be null since it is the last sink in
                // the client context
                // Assert if Invoke is called without a channel sink
                BCLDebug.Assert(false, "How did we get here?");

                throw new InvalidOperationException(
                          Environment.GetResourceString("Remoting_Proxy_InvalidState"));
            }

            if ((callType & Message.BeginAsync) != 0)
            {
                if ((callType & Message.OneWay) != 0)
                {
                    ar.SyncProcessMessage(null);
                }
            }
        }
예제 #7
0
        internal static ServerIdentity GetServerIdentity(IMessage reqMsg)
        {
            ServerIdentity   serverIdentityObject = null;
            bool             flag    = false;
            IInternalMessage message = reqMsg as IInternalMessage;

            if (message != null)
            {
                serverIdentityObject = ((IInternalMessage)reqMsg).ServerIdentityObject;
                flag = true;
            }
            else if (reqMsg is InternalMessageWrapper)
            {
                serverIdentityObject = (ServerIdentity)((InternalMessageWrapper)reqMsg).GetServerIdentityObject();
            }
            if (serverIdentityObject == null)
            {
                Identity identity2 = IdentityHolder.ResolveIdentity(GetURI(reqMsg));
                if (identity2 is ServerIdentity)
                {
                    serverIdentityObject = (ServerIdentity)identity2;
                    if (flag)
                    {
                        message.ServerIdentityObject = serverIdentityObject;
                    }
                }
            }
            return(serverIdentityObject);
        }
예제 #8
0
        internal void InternalInvokeAsync(IMessageSink ar, Message reqMsg, bool useDispatchMessage, int callType)
        {
            Identity         identityObject = this.IdentityObject;
            ServerIdentity   identity2      = identityObject as ServerIdentity;
            MethodCall       msg            = new MethodCall(reqMsg);
            IInternalMessage message        = msg;

            message.IdentityObject = identityObject;
            if (identity2 != null)
            {
                message.ServerIdentityObject = identity2;
            }
            if (useDispatchMessage)
            {
                ChannelServices.AsyncDispatchMessage(msg, ((callType & 8) != 0) ? null : ar);
            }
            else
            {
                if (identityObject.EnvoyChain == null)
                {
                    throw new InvalidOperationException(Environment.GetResourceString("Remoting_Proxy_InvalidState"));
                }
                identityObject.EnvoyChain.AsyncProcessMessage(msg, ((callType & 8) != 0) ? null : ar);
            }
            if (((callType & 1) != 0) && ((callType & 8) != 0))
            {
                ar.SyncProcessMessage(null);
            }
        }
 /// <summary>
 /// 将一个系统消息加入到队列中
 /// </summary>
 /// <param name="internalMessage">系统消息对象</param>
 public void Offer(IInternalMessage internalMessage)
 {
     lock (this)
     {
         messageQueue.Enqueue(internalMessage);
     }
 }
예제 #10
0
        internal static ServerIdentity GetServerIdentity(IMessage reqMsg)
        {
            ServerIdentity   serverIdentity  = null;
            bool             flag            = false;
            IInternalMessage internalMessage = reqMsg as IInternalMessage;

            if (internalMessage != null)
            {
                serverIdentity = ((IInternalMessage)reqMsg).ServerIdentityObject;
                flag           = true;
            }
            else if (reqMsg is InternalMessageWrapper)
            {
                serverIdentity = (ServerIdentity)((InternalMessageWrapper)reqMsg).GetServerIdentityObject();
            }
            if (serverIdentity == null)
            {
                string   uri      = InternalSink.GetURI(reqMsg);
                Identity identity = IdentityHolder.ResolveIdentity(uri);
                if (identity is ServerIdentity)
                {
                    serverIdentity = (ServerIdentity)identity;
                    if (flag)
                    {
                        internalMessage.ServerIdentityObject = serverIdentity;
                    }
                }
            }
            return(serverIdentity);
        }
        private SmuggledMethodCallMessage(IMethodCallMessage mcm)
        {
            this._uri        = mcm.Uri;
            this._methodName = mcm.MethodName;
            this._typeName   = mcm.TypeName;
            ArrayList        arrayList       = null;
            IInternalMessage internalMessage = mcm as IInternalMessage;

            if (internalMessage == null || internalMessage.HasProperties())
            {
                this._propertyCount = MessageSmuggler.StoreUserPropertiesForMethodMessage(mcm, ref arrayList);
            }
            if (mcm.MethodBase.IsGenericMethod)
            {
                Type[] genericArguments = mcm.MethodBase.GetGenericArguments();
                if (genericArguments != null && genericArguments.Length != 0)
                {
                    if (arrayList == null)
                    {
                        arrayList = new ArrayList();
                    }
                    this._instantiation = new MessageSmuggler.SerializedArg(arrayList.Count);
                    arrayList.Add(genericArguments);
                }
            }
            if (RemotingServices.IsMethodOverloaded(mcm))
            {
                if (arrayList == null)
                {
                    arrayList = new ArrayList();
                }
                this._methodSignature = new MessageSmuggler.SerializedArg(arrayList.Count);
                arrayList.Add(mcm.MethodSignature);
            }
            LogicalCallContext logicalCallContext = mcm.LogicalCallContext;

            if (logicalCallContext == null)
            {
                this._callContext = null;
            }
            else if (logicalCallContext.HasInfo)
            {
                if (arrayList == null)
                {
                    arrayList = new ArrayList();
                }
                this._callContext = new MessageSmuggler.SerializedArg(arrayList.Count);
                arrayList.Add(logicalCallContext);
            }
            else
            {
                this._callContext = logicalCallContext.RemotingData.LogicalCallID;
            }
            this._args = MessageSmuggler.FixupArgs(mcm.Args, ref arrayList);
            if (arrayList != null)
            {
                MemoryStream memoryStream = CrossAppDomainSerializer.SerializeMessageParts(arrayList);
                this._serializedArgs = memoryStream.GetBuffer();
            }
        }
 private void MessageProvider_Received(object sender, IInternalMessage e)
 {
     switch (e)
     {
     case T1 t1:
     {
         if (_siteOptions.IsIgnore50Counts && int.TryParse(t1.Cm, out int count))
         {
             if (count >= 1 && count <= 50)
             {
                 //1-50の数字のみのコメントは無視する
                 return;
             }
         }
         var message        = new ShowRoomComment(t1);
         var userId         = message.UserId;
         var isFirstComment = _first.IsFirstComment(userId);
         var user           = GetUser(userId);
         user.Name = message.NameItems;
         var metadata = CreateMessageMetadata(message, user, isFirstComment);
         var methods  = new MessageMethods();
         RaiseMessageReceived(new MessageContext(message, metadata, methods));
     }
     break;
     }
 }
예제 #13
0
        private SmuggledMethodCallMessage(IMethodCallMessage mcm)
        {
            _uri        = mcm.Uri;
            _methodName = mcm.MethodName;
            _typeName   = mcm.TypeName;

            ArrayList argsToSerialize = null;

            IInternalMessage iim = mcm as IInternalMessage;

            // user properties (everything but special entries)
            if ((iim == null) || iim.HasProperties())
            {
                _propertyCount = StoreUserPropertiesForMethodMessage(mcm, ref argsToSerialize);
            }

            // handle method signature
            if (RemotingServices.IsMethodOverloaded(mcm))
            {
                if (argsToSerialize == null)
                {
                    argsToSerialize = new ArrayList();
                }
                _methodSignature = new SerializedArg(argsToSerialize.Count);
                argsToSerialize.Add(mcm.MethodSignature);
            }

            // handle call context
            LogicalCallContext lcc = mcm.LogicalCallContext;

            if (lcc == null)
            {
                _callContext = null;
            }
            else
            if (lcc.HasInfo)
            {
                if (argsToSerialize == null)
                {
                    argsToSerialize = new ArrayList();
                }
                _callContext = new SerializedArg(argsToSerialize.Count);
                argsToSerialize.Add(lcc);
            }
            else
            {
                // just smuggle the call id string
                _callContext = lcc.RemotingData.LogicalCallID;
            }

            _args = FixupArgs(mcm.Args, ref argsToSerialize);

            if (argsToSerialize != null)
            {
                //MemoryStream argStm = CrossAppDomainSerializer.SerializeMessageParts(argsToSerialize, out _serializerSmuggledArgs);
                MemoryStream argStm = CrossAppDomainSerializer.SerializeMessageParts(argsToSerialize);
                _serializedArgs = argStm.GetBuffer();
            }
        } // SmuggledMethodCallMessage
 public void Send(IInternalMessage message)
 {
     if (message is MethodBase method)
     {
         _methodReplyDict.AddOrUpdate(method.Id, method, (n, t) => t);
     }
     _webSocket.Send(message.Raw);
 }
예제 #15
0
        public override IMessage Invoke(IMessage request)
        {
            IMethodCallMessage methodCallMessage = request as IMethodCallMessage;

            if (methodCallMessage != null)
            {
                if (methodCallMessage.MethodBase == RemotingProxy._cache_GetHashCodeMethod)
                {
                    return(new MethodResponse(base.ObjectIdentity.GetHashCode(), null, null, methodCallMessage));
                }
                if (methodCallMessage.MethodBase == RemotingProxy._cache_GetTypeMethod)
                {
                    return(new MethodResponse(base.GetProxiedType(), null, null, methodCallMessage));
                }
            }
            IInternalMessage internalMessage = request as IInternalMessage;

            if (internalMessage != null)
            {
                if (internalMessage.Uri == null)
                {
                    internalMessage.Uri = this._targetUri;
                }
                internalMessage.TargetIdentity = this._objectIdentity;
            }
            this._objectIdentity.NotifyClientDynamicSinks(true, request, true, false);
            IMessageSink messageSink;

            if (Thread.CurrentContext.HasExitSinks && !this._hasEnvoySink)
            {
                messageSink = Thread.CurrentContext.GetClientContextSinkChain();
            }
            else
            {
                messageSink = this._sink;
            }
            MonoMethodMessage monoMethodMessage = request as MonoMethodMessage;
            IMessage          result;

            if (monoMethodMessage == null || monoMethodMessage.CallType == CallType.Sync)
            {
                result = messageSink.SyncProcessMessage(request);
            }
            else
            {
                AsyncResult  asyncResult = monoMethodMessage.AsyncResult;
                IMessageCtrl messageCtrl = messageSink.AsyncProcessMessage(request, asyncResult);
                if (asyncResult != null)
                {
                    asyncResult.SetMessageCtrl(messageCtrl);
                }
                result = new ReturnMessage(null, new object[0], 0, null, monoMethodMessage);
            }
            this._objectIdentity.NotifyClientDynamicSinks(false, request, true, false);
            return(result);
        }
        internal bool IsOKToStackBlt(IMethodMessage mcMsg, object server)
        {
            bool    result  = false;
            Message message = mcMsg as Message;

            if (message != null)
            {
                IInternalMessage internalMessage = message;
                if (message.GetFramePtr() != IntPtr.Zero && message.GetThisPtr() == server && (internalMessage.IdentityObject == null || (internalMessage.IdentityObject != null && internalMessage.IdentityObject == internalMessage.ServerIdentityObject)))
                {
                    result = true;
                }
            }
            return(result);
        }
예제 #17
0
 private void MetaProvider_MessageReceived(object sender, IInternalMessage e)
 {
     switch (e)
     {
     case ICurrentRoom currentRoom:
     {
         //currentRoom.MessageServerUri
         _messageUrl = currentRoom.MessageServerUri;
         _threadId   = currentRoom.ThreadId;
         _roomName   = currentRoom.RoomName;
         _tcs.SetResult(null);
     }
     break;
     }
 }
        private void P1_MessageReceived(object sender, IInternalMessage e)
        {
            var internalMessage = e;

            switch (internalMessage)
            {
            case InternalComment comment:
            {
                _lastCommentId = comment.Id;
                var context = CreateMessageContext(comment, false);
                RaiseMessageReceived(context);
            }
            break;
            }
        }
        internal object GetServerIdentityObject()
        {
            IInternalMessage internalMessage = this.WrappedMessage as IInternalMessage;

            if (internalMessage != null)
            {
                return(internalMessage.ServerIdentityObject);
            }
            InternalMessageWrapper internalMessageWrapper = this.WrappedMessage as InternalMessageWrapper;

            if (internalMessageWrapper != null)
            {
                return(internalMessageWrapper.GetServerIdentityObject());
            }
            return(null);
        }
예제 #20
0
        internal object GetIdentityObject()
        {
            IInternalMessage wrappedMessage = this.WrappedMessage as IInternalMessage;

            if (wrappedMessage != null)
            {
                return(wrappedMessage.IdentityObject);
            }
            InternalMessageWrapper wrapper = this.WrappedMessage as InternalMessageWrapper;

            if (wrapper != null)
            {
                return(wrapper.GetIdentityObject());
            }
            return(null);
        }
예제 #21
0
        public void SetMessage(IInternalMessage internalMessage)
        {
            if (internalMessage is EnterRoom)
            {
                _isBeeingSentInitialComments = true;
            }
            else if (_isBeeingSentInitialComments && !(internalMessage is OnChatMessage))
            {
                _isBeeingSentInitialComments = false;
            }
            var messageContext = CreateMessageContext(internalMessage);

            if (messageContext != null)
            {
                RaiseMessageReceived(messageContext);
            }
        }
        internal bool IsOKToStackBlt(IMethodMessage mcMsg, object server)
        {
            bool    flag    = false;
            Message message = mcMsg as Message;

            if (message == null)
            {
                return(flag);
            }
            IInternalMessage message2 = message;

            if ((!(message.GetFramePtr() != IntPtr.Zero) || (message.GetThisPtr() != server)) || ((message2.IdentityObject != null) && ((message2.IdentityObject == null) || (message2.IdentityObject != message2.ServerIdentityObject))))
            {
                return(flag);
            }
            return(true);
        }
 private void P1_MessageReceived(object sender, IInternalMessage e)
 {
     if (e is Kind1Type1 kind1Type1)
     {
         var message        = new PeriscopeComment(kind1Type1);
         var userId         = message.UserId;
         var isFirstComment = _first.IsFirstComment(userId);
         var user           = GetUser(userId);
         user.Name = MessagePartFactory.CreateMessageItems(message.Text);
         var metadata = CreateMessageMetadata(message, user, isFirstComment);
         var methods  = new MessageMethods();
         RaiseMessageReceived(new MessageContext(message, metadata, methods));
     }
     else if (e is Kind2Kind1 kind2kind1)
     {
         if (!_siteOptions.IsShowJoinMessage)
         {
             //取得する必要がないため無視する
             return;
         }
         var message        = new PeriscopeJoin(kind2kind1);
         var userId         = message.UserId;
         var isFirstComment = false;
         var user           = GetUser(userId);
         user.Name = MessagePartFactory.CreateMessageItems(message.DisplayName);
         var metadata = CreateMessageMetadata(message, user, isFirstComment);
         var methods  = new MessageMethods();
         RaiseMessageReceived(new MessageContext(message, metadata, methods));
     }
     else if (e is Kind2Kind2 kind2Kind2)
     {
         if (!_siteOptions.IsShowLeaveMessage)
         {
             //取得する必要がないため無視する
             return;
         }
         var message        = new PeriscopeLeave(kind2Kind2);
         var userId         = message.UserId;
         var isFirstComment = false;
         var user           = GetUser(userId);
         user.Name = MessagePartFactory.CreateMessageItems(message.DisplayName);
         var metadata = CreateMessageMetadata(message, user, isFirstComment);
         var methods  = new MessageMethods();
         RaiseMessageReceived(new MessageContext(message, metadata, methods));
     }
 }
예제 #24
0
        public override async void SetMessage(string rawMessage)
        {
            IInternalMessage internalMessage = null;

            try
            {
                internalMessage = MessageParser.Parse(rawMessage, _imageDict);
            }
            catch (Exception ex)
            {
                _logger.LogException(ex, "", $"raw={rawMessage}");
            }
            if (internalMessage == null)
            {
                SendSystemInfo($"ParseError: {rawMessage}", InfoType.Error);
                return;
            }
            SetMessage(internalMessage);
        }
예제 #25
0
        internal void PropagateIncomingHeadersToCallContext(IMessage msg)
        {
            IInternalMessage internalMessage = msg as IInternalMessage;

            if (internalMessage != null && !internalMessage.HasProperties())
            {
                return;
            }
            IDictionary           properties = msg.Properties;
            IDictionaryEnumerator enumerator = properties.GetEnumerator();
            int num = 0;

            while (enumerator.MoveNext())
            {
                string text = (string)enumerator.Key;
                if (!text.StartsWith("__", StringComparison.Ordinal) && enumerator.Value is Header)
                {
                    num++;
                }
            }
            Header[] array = null;
            if (num > 0)
            {
                array = new Header[num];
                num   = 0;
                enumerator.Reset();
                while (enumerator.MoveNext())
                {
                    string text2 = (string)enumerator.Key;
                    if (!text2.StartsWith("__", StringComparison.Ordinal))
                    {
                        Header header = enumerator.Value as Header;
                        if (header != null)
                        {
                            array[num++] = header;
                        }
                    }
                }
            }
            this._recvHeaders = array;
            this._sendHeaders = null;
        }
예제 #26
0
        private void ProcessAction(IInternalMessage action)
        {
            switch (action)
            {
            case InternalComment comment:
                MessageReceived?.Invoke(this, comment);
                break;

            case InternalSuperChat superChat:
                MessageReceived?.Invoke(this, superChat);
                break;

            case InternalMembership membership:
                MessageReceived?.Invoke(this, membership);
                break;

            default:
                break;
            }
        }
예제 #27
0
        private object[] WriteMethodCall(IMethodCallMessage mcm)
        {
            string uri             = mcm.Uri;
            string methodName      = mcm.MethodName;
            string typeName        = mcm.TypeName;
            object methodSignature = null;
            object callContext     = null;

            object[] properties = null;
            Type[]   instArgs   = null;
            if (mcm.MethodBase.IsGenericMethod)
            {
                instArgs = mcm.MethodBase.GetGenericArguments();
            }
            object[]         args    = mcm.Args;
            IInternalMessage message = mcm as IInternalMessage;

            if ((message == null) || message.HasProperties())
            {
                properties = StoreUserPropertiesForMethodMessage(mcm);
            }
            if ((mcm.MethodSignature != null) && RemotingServices.IsMethodOverloaded(mcm))
            {
                methodSignature = mcm.MethodSignature;
            }
            LogicalCallContext logicalCallContext = mcm.LogicalCallContext;

            if (logicalCallContext == null)
            {
                callContext = null;
            }
            else if (logicalCallContext.HasInfo)
            {
                callContext = logicalCallContext;
            }
            else
            {
                callContext = logicalCallContext.RemotingData.LogicalCallID;
            }
            return(this.serWriter.WriteCallArray(uri, methodName, typeName, instArgs, args, methodSignature, callContext, properties));
        }
예제 #28
0
        private void P1_MessageReceived(object sender, IInternalMessage e)
        {
            var internalMessage = e;

            switch (internalMessage)
            {
            case ChatMessageData chat:
                var context = CreateMessageContext(chat);
                RaiseMessageReceived(context);
                break;

            case UserUpdateEvent userUpdate:
                break;

            case DeleteMessageEvent deleteMessage:
                break;

            default:
                break;
            }
        }
        [System.Security.SecurityCritical]  // auto-generated
        internal static ServerIdentity GetServerIdentity(IMessage reqMsg)
        {
            ServerIdentity srvID   = null;
            bool           bOurMsg = false;
            String         objURI  = null;

            IInternalMessage iim = reqMsg as IInternalMessage;

            if (iim != null)
            {
                Message.DebugOut("GetServerIdentity.ServerIdentity from IInternalMessage\n");
                srvID   = ((IInternalMessage)reqMsg).ServerIdentityObject;
                bOurMsg = true;
            }
            else if (reqMsg is InternalMessageWrapper)
            {
                srvID = (ServerIdentity)((InternalMessageWrapper)reqMsg).GetServerIdentityObject();
            }

            // Try the slow path if the identity has not been obtained yet
            if (null == srvID)
            {
                Message.DebugOut("GetServerIdentity.ServerIdentity from IMethodCallMessage\n");
                objURI = GetURI(reqMsg);
                Identity id =
                    IdentityHolder.ResolveIdentity(objURI);
                if (id is ServerIdentity)
                {
                    srvID = (ServerIdentity)id;

                    // Cache the serverIdentity in the message
                    if (bOurMsg)
                    {
                        iim.ServerIdentityObject = srvID;
                    }
                }
            }

            return(srvID);
        }
예제 #30
0
        public async Task Publish(IInternalMessage message)
        {
            Type incomingMessageType = message.GetType();

            KeyValuePair <Type, Dictionary <object, Subscriber> >[] typesAndSubscribersArr = null;

            lock (typesAndSubscribers)
            {
                typesAndSubscribersArr = typesAndSubscribers.ToArray();
            }

            foreach (KeyValuePair <Type, Dictionary <object, Subscriber> > typesAndSubs in typesAndSubscribersArr)
            {
                Type type = typesAndSubs.Key;
                if (incomingMessageType.Is(type))
                {
                    KeyValuePair <object, Subscriber>[] subscribersArr = null;

                    lock (typesAndSubscribers)
                    {
                        subscribersArr = typesAndSubs.Value.ToArray();
                    }

                    foreach (KeyValuePair <object, Subscriber> subscriber in subscribersArr)
                    {
                        Func <IInternalMessage, Task>[] actionsArr = null;

                        lock (typesAndSubscribers)
                        {
                            actionsArr = subscriber.Value.Actions.ToArray();
                        }

                        foreach (Func <IInternalMessage, Task> action in actionsArr)
                        {
                            await action(message);
                        }
                    }
                }
            }
        }
        internal void PropagateIncomingHeadersToCallContext(IMessage msg)
        {
            IInternalMessage message = msg as IInternalMessage;

            if ((message == null) || message.HasProperties())
            {
                IDictionaryEnumerator enumerator = msg.Properties.GetEnumerator();
                int num = 0;
                while (enumerator.MoveNext())
                {
                    string key = (string)enumerator.Key;
                    if (!key.StartsWith("__", StringComparison.Ordinal) && (enumerator.Value is Header))
                    {
                        num++;
                    }
                }
                Header[] headerArray = null;
                if (num > 0)
                {
                    headerArray = new Header[num];
                    num         = 0;
                    enumerator.Reset();
                    while (enumerator.MoveNext())
                    {
                        string str2 = (string)enumerator.Key;
                        if (!str2.StartsWith("__", StringComparison.Ordinal))
                        {
                            Header header = enumerator.Value as Header;
                            if (header != null)
                            {
                                headerArray[num++] = header;
                            }
                        }
                    }
                }
                this._recvHeaders = headerArray;
                this._sendHeaders = null;
            }
        }