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


C# IMessage.ToString方法代码示例

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


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

示例1: onMessage

        public void onMessage(IClientSessionChannel channel, IMessage message)
        {
            var data = message.DataAsDictionary;
            #if DEBUG
            Console.WriteLine(message.ToString());
            #endif

            string command = this.GetString(data, "command");
            switch (command)
            {
                case "status":
                case "statusOK":
                case "statusFAIL":
                    string computer = this.GetString(data, "computer");
                    string statusMessage = this.GetString(data, "status");

                    Console.WriteLine(string.Format("{0} - {1}", computer, statusMessage));

                    Status status;
                    if (command == "statusOK")
                        status = Status.Successful;
                    else if (command == "statusFAIL")
                        status = Status.Failure;
                    else
                        status = Status.Information;

                    var handler = this.StatusReceived;
                    if (handler != null)
                        handler(this, new StatusEventArgs(computer, status, statusMessage));
                    break;
            }
        }
开发者ID:HakanL,项目名称:Auto-Deployment,代码行数:32,代码来源:MsgListener.cs

示例2: TraitementPREappel

        private void TraitementPREappel(IMessage msg)
        {
            if (msg is IMethodCallMessage) frmDemoInterceptionAppel.LogInfo(" is IMethodCallMessage");
            if (msg is IMethodMessage) frmDemoInterceptionAppel.LogInfo(" is IMethodMessage");

            if (msg is IMethodCallMessage)
            {
                IMethodCallMessage mcmsg=msg as IMethodCallMessage;
                string logtxt="Appel de " + mcmsg.MethodName;
                frmDemoInterceptionAppel.LogInfo(logtxt);
            }
            else frmDemoInterceptionAppel.LogInfo("PRE :" + msg.ToString());
        }
开发者ID:flyingoverclouds,项目名称:sfinx,代码行数:13,代码来源:InterceptionAppelSink.cs

示例3: guessTheWord

        public void guessTheWord(IMessage message)
        {
            if (message.ToString().Equals(gameRoom.Word, StringComparison.CurrentCultureIgnoreCase) == true)
            {
                gameRoom.WinnerId = user.Id;

                ServerContext.Instance.roomServices.addRoom(gameRoom);

                this.InvokeTo(c => c.gameRoom.Id == gameRoom.Id, gameRoom, "win");

                gameRoom = null;
            }
            else
            {
                this.InvokeTo(c => c.gameRoom.Id == gameRoom.Id, new UserMessage() { message = message.Data, user = user}, "wrong");
            }
        }
开发者ID:RS2projekat,项目名称:guesstheword,代码行数:17,代码来源:GameRoomActiveController.cs

示例4: ClientServiceCallback

 // just for logging purposes
 private static void ClientServiceCallback(IMessage msg)
 {
     Console.WriteLine("{0}", msg.DescriptorForType.FullName);
     Console.WriteLine("{0}", msg.ToString());
 }
开发者ID:Geracl,项目名称:d3proto,代码行数:6,代码来源:AuthenticationServerImpl.cs

示例5: MessageHandler

 private static void MessageHandler(IMessage msg)
 {
     //  Log incoming messages
     Log.Info(msg.ToString());
 }
开发者ID:visual14ph,项目名称:f1livetiming,代码行数:5,代码来源:Program.cs

示例6: ServiceMessage

        public override IMessage ServiceMessage(IMessage message)
        {
            if (FluorineContext.Current.Client != null)
                FluorineContext.Current.Client.Renew();

            if (message is CommandMessage)
            {
                CommandMessage commandMessage = message as CommandMessage;
                switch (commandMessage.operation)
                {
                    case CommandMessage.PollOperation:
                        {
                            if (log.IsDebugEnabled)
                                log.Debug(__Res.GetString(__Res.Endpoint_HandleMessage, this.Id, message.ToString()));

                            if (FluorineContext.Current.Client != null)
                                FluorineContext.Current.Client.Renew();

                            //IMessage[] messages = null;
                            IList messages = null;
                            _waitingPollRequests.Increment();
                            int waitIntervalMillis = this.ChannelDefinition.Properties.WaitIntervalMillis != -1 ? this.ChannelDefinition.Properties.WaitIntervalMillis : 60000;// int.MaxValue;

                            if (commandMessage.HeaderExists(CommandMessage.FluorineSuppressPollWaitHeader))
                                waitIntervalMillis = 0;
                            //If async handling was not set long polling is not supported
                            if (!FluorineConfiguration.Instance.FluorineSettings.Runtime.AsyncHandler)
                                waitIntervalMillis = 0;
                            if (this.ChannelDefinition.Properties.MaxWaitingPollRequests <= 0 || _waitingPollRequests.Value >= this.ChannelDefinition.Properties.MaxWaitingPollRequests)
                                waitIntervalMillis = 0;

                            if (message.destination != null && message.destination != string.Empty)
                            {
                                string clientId = commandMessage.clientId as string;
                                MessageDestination messageDestination = this.GetMessageBroker().GetDestination(message.destination) as MessageDestination;
                                MessageClient client = messageDestination.SubscriptionManager.GetSubscriber(clientId);
                                client.Renew();
                                //messages = client.GetPendingMessages();
                            }
                            else
                            {
                                //if (FluorineContext.Current.Client != null)
                                //    messages = FluorineContext.Current.Client.GetPendingMessages(waitIntervalMillis);
                            }

                            if (FluorineContext.Current.Client != null)
                            {
                                IEndpointPushHandler handler = FluorineContext.Current.Client.GetEndpointPushHandler(this.Id);
                                if (handler != null)
                                    messages = handler.GetPendingMessages();
                                if (messages == null)
                                {
                                    lock (handler.SyncRoot)
                                    {
                                        Monitor.Wait(handler.SyncRoot, waitIntervalMillis);
                                    }
                                    messages = handler.GetPendingMessages();
                                }
                            }

                            _waitingPollRequests.Decrement();
                            IMessage response = null;
                            if (messages == null || messages.Count == 0)
                                response = new AcknowledgeMessage();
                            else
                            {
                                CommandMessage resultMessage = new CommandMessage();
                                resultMessage.operation = CommandMessage.ClientSyncOperation;
                                resultMessage.body = messages;
                                response = resultMessage;
                            }
                            if (log.IsDebugEnabled)
                                log.Debug(__Res.GetString(__Res.Endpoint_Response, this.Id, response.ToString()));
                            return response;

                        }
                    case CommandMessage.SubscribeOperation:
                        {
                            /*
                            if (FluorineContext.Current.Client == null)
                                FluorineContext.Current.SetCurrentClient(this.GetMessageBroker().ClientRegistry.GetClient(message));
                            RemotingConnection remotingConnection = null;
                            foreach (IConnection connection in FluorineContext.Current.Client.Connections)
                            {
                                if (connection is RemotingConnection)
                                {
                                    remotingConnection = connection as RemotingConnection;
                                    break;
                                }
                            }
                            if (remotingConnection == null)
                            {
                                remotingConnection = new RemotingConnection(this, null, FluorineContext.Current.Client.Id, null);
                                FluorineContext.Current.Client.Renew(this.ClientLeaseTime);
                                remotingConnection.Initialize(FluorineContext.Current.Client);
                            }
                            FluorineWebContext webContext = FluorineContext.Current as FluorineWebContext;
                            webContext.SetConnection(remotingConnection);
                            */

//.........这里部分代码省略.........
开发者ID:Nicholi,项目名称:fluorinefx-mod,代码行数:101,代码来源:AMFEndpoint.cs

示例7: onMessage

 public void onMessage(IClientSessionChannel channel, IMessage message)
 {
     #if DEBUG
     Console.WriteLine("META: " + message.ToString());
     #endif
 }
开发者ID:HakanL,项目名称:Auto-Deployment,代码行数:6,代码来源:MetaListener.cs

示例8: ModuleLoadResponse

 private static void ModuleLoadResponse(IMessage response)
 {
     Logger.Trace("ModuleLoadResponse(): {0}", response.ToString());
 }
开发者ID:rinoa,项目名称:mooege-1,代码行数:4,代码来源:AuthManager.cs

示例9: RouteMessage

		/// <summary>
		/// Call this method in order to send a message from your code into the message routing system.
		/// The message is routed to a service that is defined to handle messages of this type.
		/// Once the service is identified, the destination property of the message is used to find a destination configured for that service.
		/// The adapter defined for that destination is used to handle the message.
		/// </summary>
		/// <param name="message">The message to be routed to a service.</param>
		/// <param name="endpoint">This can identify the endpoint that is sending the message but it is currently not used so you may pass in null.</param>
        /// <returns>The result of the message routing.</returns>
		internal IMessage RouteMessage(IMessage message, IEndpoint endpoint)
		{
			IService service = null;
			object result = null;
			IMessage responseMessage = null;

            if( log.IsDebugEnabled )
                log.Debug(__Res.GetString(__Res.MessageBroker_RoutingMessage, message.ToString()));

			CommandMessage commandMessage = message as CommandMessage;
			if( commandMessage != null && (commandMessage.operation == CommandMessage.LoginOperation || commandMessage.operation == CommandMessage.LogoutOperation) )//Login, Logout
			{
				try
				{
					service = GetService(AuthenticationService.ServiceId);
					result = service.ServiceMessage(commandMessage);
					responseMessage = result as IMessage;
				}
                catch (UnauthorizedAccessException uae)
                {
                    if (log.IsDebugEnabled)
                        log.Debug(uae.Message);
                    responseMessage = ErrorMessage.GetErrorMessage(message, uae);
                }
                catch (SecurityException exception)
                {
                    if (log.IsDebugEnabled)
                        log.Debug(exception.Message);
                    responseMessage = ErrorMessage.GetErrorMessage(message, exception);
                }
				catch(Exception exception)
				{
					if(log.IsErrorEnabled)
						log.Error(__Res.GetString(__Res.MessageBroker_RoutingError), exception);
					responseMessage = ErrorMessage.GetErrorMessage(message, exception);
				}
			}
            else if (commandMessage != null && commandMessage.operation == CommandMessage.ClientPingOperation)
            {
                responseMessage = new AcknowledgeMessage();
                responseMessage.body = true;
            }
            else
            {
				//The only case when context is not set should be when one starts a new thread in the backend
                //if( FluorineContext.Current != null )
                //    FluorineContext.Current.RestorePrincipal(this.LoginCommand);
                _loginManager.RestorePrincipal();
				service = GetService(message);
                if (service != null)
                {
                    try
                    {
                        service.CheckSecurity(message);
                        result = service.ServiceMessage(message);
                    }
                    catch (UnauthorizedAccessException uae)
                    {
                        if (log.IsDebugEnabled)
                            log.Debug(uae.Message);
                        result = ErrorMessage.GetErrorMessage(message, uae);
                    }
                    catch (SecurityException exception)
                    {
                        if (log.IsDebugEnabled)
                            log.Debug(exception.Message);
                        result = ErrorMessage.GetErrorMessage(message, exception);
                    }
                    catch (ServiceException exception)
                    {
                        if (log.IsDebugEnabled)
                            log.Debug(exception.Message);
                        result = ErrorMessage.GetErrorMessage(message, exception);
                    }
                    catch (Exception exception)
                    {
                        if (log.IsErrorEnabled)
                            log.Error(exception.Message, exception);
                        result = ErrorMessage.GetErrorMessage(message, exception);
                    }
                }
                else
                {
                    string msg = __Res.GetString(__Res.Destination_NotFound, message.destination);
                    if (log.IsErrorEnabled)
                        log.Error(msg);
                    result = ErrorMessage.GetErrorMessage(message, new FluorineException(msg));
                }
                if (!(result is IMessage))
                {
                    responseMessage = new AcknowledgeMessage();
//.........这里部分代码省略.........
开发者ID:Nicholi,项目名称:fluorinefx-mod,代码行数:101,代码来源:MessageBroker.cs

示例10: Send

            public void Send(IMessage msg)
            {
                try
                {
                    // Only send retry once for each connection
                    if (IsRetrySent)
                        msg.Retry = null;

                    var text = msg.ToString();
                    StreamWriter.WriteLine(text);
                    StreamWriter.Flush();

                    if(!Message.IsOnlyComment(msg))
                        LastMessageId = msg.Id;

                    if (!string.IsNullOrWhiteSpace(msg.Retry))
                        IsRetrySent = true;
                }
                catch (HttpException ex)
                {
                    if (ex.ErrorCode == -2147023667) // The remote host closed the connection.
                    {
                        IsConnected = false;
                    }
                }
                catch (System.ServiceModel.CommunicationException)
                {
                    IsConnected = false;
                }
            }
开发者ID:erizet,项目名称:ServerSentEvent4Net,代码行数:30,代码来源:ServerSentEvent.cs

示例11: Process

        /// <summary>
        /// 对消息进行处理
        /// </summary>
        /// <param name="message">需处理的消息</param>
        /// <param name="logger">日志对象</param>
        /// todo:增加日志功能,需要设计变更
        public void Process(IMessage message, ILogger logger)
        {
            //if (logger != null && message != null)
            //{
            //	logger.WriteLog(Mysoft.ESB.Entity.Enumeration.LogLevel.Info, string.Format("{0}处理器Process前的日志", this.GetType().Name), message.ToString());
            //}

            this.EnterProcess(message);

            if (this.nextHandler != null)
            {
                this.nextHandler.Process(message, logger);
            }

            this.ReturnProcess(message);

            if (logger != null && message != null)
            {
                logger.WriteLog(Mysoft.ESB.Entity.Enumeration.LogLevel.Info, string.Format("{0}处理器Process后的日志", this.GetType().Name), message.ToString());
            }
        }
开发者ID:udbeeq5566,项目名称:ESB,代码行数:27,代码来源:MessageHandler.cs

示例12: setTheWord

        public bool setTheWord(IMessage message)
        {
            try
            {

                gameRoom.Word = message.ToString();
                return true;

            }
            catch(Exception e)
            {
                return false;
            }
        }
开发者ID:RS2projekat,项目名称:guesstheword,代码行数:14,代码来源:GameRoomActiveController.cs

示例13: onMessage

        public void onMessage(IClientSessionChannel channel, IMessage message)
        {
            if (message.Channel.Equals(Channel_Fields.META_HANDSHAKE))
            {
                subscribed = false;
            }

            if (message.Channel.Equals(Channel_Fields.META_CONNECT) && message.Successful)
            {
                if (!subscribed)
                {
                    // Subscribe
                    callEventChannel.subscribe(this);
                    subscribed = true;
                }
            }

            if (message.ChannelId.ToString().Equals(channelId))
            {
                // Our message
                var data = message.DataAsDictionary;

                NameValueCollection nvc = new NameValueCollection(data.Count);
                foreach (var kvp in data)
                    nvc.Add(kvp.Key, kvp.Value.ToString());

                string command = nvc["command"];
                if (string.IsNullOrEmpty(command) || command == "status")
                    return;

                log.InfoFormat("Received command = {0}", command);

                string computer = nvc["computer"];
                if (!string.IsNullOrEmpty(computer) && !computer.Equals(Environment.MachineName, StringComparison.OrdinalIgnoreCase))
                    return;

                switch (command)
                {
                    case "deploy":
                        RaiseUpdateAvailable(nvc);
                        break;
                    case "ping":
                        PublishStatus("Pong");
                        break;
                }

                return;
            }

            try
            {
                log.Debug("Message on " + message.ChannelId.ToString() + "   Data: " + message.ToString());
            }
            catch
            {
            }
        }
开发者ID:HakanL,项目名称:Auto-Deployment,代码行数:57,代码来源:NotifyClient.cs

示例14: Deserialize

        public static IMessage Deserialize(BinaryReader reader, IMessage messageBase)
        {
            var messageType = messageBase.GetType();
            var fieldInfo = messageType.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);

            var attributeCount = reader.ReadByte();

            for (int i = 0; i < attributeCount; i++)
            {
                // TODO: Be brave enough to find an elegant fix for this
                // XFire decides not to follow its own rules. Message type 32 does not have a prefix byte for the length of the attribute name
                // and breaks this code. Assume first byte after the attribute count as the attribute name
                string attributeName = null;
                if (messageType == typeof(StatusChange))
                {
                    attributeName = Encoding.UTF8.GetString(reader.ReadBytes(1));
                }
                else
                {
                    var attributeNameLength = reader.ReadByte();
                    attributeName = Encoding.UTF8.GetString(reader.ReadBytes(attributeNameLength));
                }
                var attributeType = reader.ReadByte();

                dynamic value = XFireAttributeFactory.Instance.GetAttribute(attributeType).ReadValue(reader);

                var field = fieldInfo.Where(a => a.GetCustomAttribute<XFireAttributeDef>() != null)
                    .FirstOrDefault(a => a.GetCustomAttribute<XFireAttributeDef>().Name == attributeName);

                if (field != null)
                {
                    field.SetValue(messageBase, value);
                }
                else
                {
                    Debug.WriteLine(string.Format("WARN: No attribute defined for {0} on class {1}", attributeName, messageType.Name));
                }
            }

            Debug.WriteLine("Deserialized [{0}]: {1}", messageType, messageBase.ToString());

            return messageBase as IMessage;
        }
开发者ID:darcymiranda,项目名称:PFire,代码行数:43,代码来源:MessageSerializer.cs

示例15: ProcessInThread

        private void ProcessInThread(IMessage processor, string replyTo, string method, object args)
        {
            try
            {
                // TODO: vladi: implement the long running part
                //if (processor.GetType().GetMethod(method) != null)
                if (processor != null)
                {
                    if (processor.IsLongRunning())
                    {
                        if (this.RestartingAgent)
                        {
                            RemoteException exception = new RemoteException("restarting agent");
                            // todo: vlad: fix the hash here
                            this.Publish(replyTo, exception.ToHash().ToString());
                        }
                        else
                        {
                            this.Lock.WaitOne();
                            try
                            {
                                if (this.LongRunningAgentTask.Count == 0)
                                {
                                    this.ProcessLongRunning(replyTo, processor, args);
                                }
                                else
                                {
                                    RemoteException exception = new RemoteException("already running long running task");
                                    // todo: vlad: fix the hash here
                                    this.Publish(replyTo, exception.ToHash().ToString());
                                }
                            }
                            finally
                            {
                                this.Lock.ReleaseMutex();
                            }
                        }
                    }
                    else
                    {
                        string payload = this.Process(processor, args);

                        if (Config.Configure != null && (method == "prepare_network_change"))
                        {
                            // todo: vladi: fix payload
                            this.Publish(replyTo, payload, () => PostPrepareNetworkChange());
                        }
                        else
                        {
                            // todo: vladi: fix payload
                            this.Publish(replyTo, payload.ToString());
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                // since this is running in a thread we're going to be nice and
                // log an error as this would otherwise be lost
                Logger.Error("{0}: {1)", processor.ToString(), ex.ToString());
            }
        }
开发者ID:UhuruSoftware,项目名称:bosh-dotnet,代码行数:63,代码来源:Handler.cs


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