当前位置: 首页>>代码示例>>C#>>正文


C# IMessage.Copy方法代码示例

本文整理汇总了C#中IMessage.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# IMessage.Copy方法的具体用法?C# IMessage.Copy怎么用?C# IMessage.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMessage的用法示例。


在下文中一共展示了IMessage.Copy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnPushEnd

        /*
        void OnPushEnd(IAsyncResult result)
        {
            EndPushMessageToClients(result);
        }
        */

        /// <summary>
        /// Pushes a message to the specified clients (subscribers).
        /// </summary>
        /// <param name="subscribers">Collection of subscribers.</param>
        /// <param name="message">The Message to push to the subscribers.</param>
        /// <remarks>
        /// The Collection of subscribers is a collection of client Id strings.
        /// </remarks>
        public void PushMessageToClients(ICollection subscribers, IMessage message)
		{
			MessageDestination destination = GetDestination(message) as MessageDestination;
			SubscriptionManager subscriptionManager = destination.SubscriptionManager;
			if( subscribers != null && subscribers.Count > 0 )
			{
				IMessage messageClone = message.Copy() as IMessage;
                /*
				if( subscribers.Count > 1 )
				{
					messageClone.SetHeader(MessageBase.DestinationClientIdHeader, BinaryMessage.DestinationClientGuid);
					messageClone.clientId = BinaryMessage.DestinationClientGuid;
					//Cache the message
					MemoryStream ms = new MemoryStream();
					AMFSerializer amfSerializer = new AMFSerializer(ms);
					//TODO this should depend on endpoint settings 
					amfSerializer.UseLegacyCollection = false;
					amfSerializer.WriteData(ObjectEncoding.AMF3, messageClone);
					amfSerializer.Flush();
					byte[] cachedContent = ms.ToArray();
					ms.Close();
					BinaryMessage binaryMessage = new BinaryMessage();
					binaryMessage.body = cachedContent;
					//binaryMessage.Prepare();
					messageClone = binaryMessage;
				}
                */
				foreach(string clientId in subscribers)
				{
					MessageClient client = subscriptionManager.GetSubscriber(clientId);
					if( client == null )
						continue;
					if (log.IsDebugEnabled)
					{
						if( messageClone is BinaryMessage )
							log.Debug(__Res.GetString(__Res.MessageServicePushBinary, message.GetType().Name, clientId));
						else
                            log.Debug(__Res.GetString(__Res.MessageServicePush, message.GetType().Name, clientId));
					}

					IEndpoint endpoint = _messageBroker.GetEndpoint(client.EndpointId);
                    if (endpoint != null)
                        endpoint.Push(messageClone, client);
                    else
                    {
                        //We should never get here
                        if( log.IsErrorEnabled)
                            log.Error(string.Format("Missing endpoint for message client {0}", client.ClientId));
                    }
				}
			}
		}
开发者ID:apakian,项目名称:fluorinefx,代码行数:67,代码来源:MessageService.cs

示例2: Push

 public override void Push(IMessage message, MessageClient messageClient)
 {
     IEndpointPushHandler handler = messageClient.Client.GetEndpointPushHandler(this.Id);
     if (handler != null)
     {
         IMessage messageClone = message.Copy() as IMessage;
         messageClone.SetHeader(MessageBase.DestinationClientIdHeader, messageClient.ClientId);
         messageClone.clientId = messageClient.ClientId;
         handler.PushMessage(messageClone);
     }
     /*
     IMessage messageClone = message.Clone() as IMessage;
     messageClone.SetHeader(MessageBase.DestinationClientIdHeader, messageClient.ClientId);
     messageClone.clientId = messageClient.ClientId;
     messageClient.AddMessage(messageClone);
     */
 }
开发者ID:Boreeas,项目名称:LoLNotes,代码行数:17,代码来源:StreamingAmfEndpoint.cs

示例3: Push

 public override void Push(IMessage message, MessageClient messageClient)
 {
     if (this.ChannelDefinition.Properties.IsPollingEnabled)
     {
         IEndpointPushHandler handler = messageClient.Client.GetEndpointPushHandler(this.Id);
         if (handler != null)
         {
             IMessage messageClone = message.Copy() as IMessage;
             messageClone.SetHeader(MessageBase.DestinationClientIdHeader, messageClient.ClientId);
             messageClone.clientId = messageClient.ClientId;
             handler.PushMessage(messageClone);
         }
         /*
         IMessage messageClone = message.Clone() as IMessage;
         messageClone.SetHeader(MessageBase.DestinationClientIdHeader, messageClient.ClientId);
         messageClone.clientId = messageClient.ClientId;
         messageClient.AddMessage(messageClone);
         */
     }
     else
     {
         if (log.IsWarnEnabled)
             log.Warn("Push request received for the non-polling AMF endpoint '" + this.Id + "'");
     }
 }
开发者ID:Nicholi,项目名称:fluorinefx-mod,代码行数:25,代码来源:AMFEndpoint.cs


注:本文中的IMessage.Copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。