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


C# Message.GetData方法代码示例

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


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

示例1: SendBadLanguageWarningToSender

        private static void SendBadLanguageWarningToSender(Message incomingMessage, IClient sender)
        {
            Message message = new Message
            {
                channel = incomingMessage.channel,
            };

            string senderName = incomingMessage.GetData<string>("sender");

            message.SetData("message", string.Format("Please don't use such fowl language, {0}.", senderName));

            sender.Enqueue(message);
            sender.FlushQueue();
        }
开发者ID:vc3,项目名称:aspComet,代码行数:14,代码来源:BadLanguageBlocker.cs

示例2: InformChannelOfBadLanguage

        private void InformChannelOfBadLanguage(Message incomingMessage, IClient sender)
        {
            string warning = "Beware; " + incomingMessage.GetData<string>("sender") + " has received a warning about his language";
            Message message = new Message
            {
                channel = incomingMessage.channel,
            };

            message.SetData("message", warning);

            foreach (Client subscriber in this.clientRepository.WhereSubscribedTo(incomingMessage.channel).Where(c => c.ID != sender.ID))
            {
                subscriber.Enqueue(message);
                subscriber.FlushQueue();
            }
        }
开发者ID:vc3,项目名称:aspComet,代码行数:16,代码来源:BadLanguageBlocker.cs

示例3: TestGoodData

        private void TestGoodData(string[] messageData, string expectedData)
        {
            Mocks mocks = new Mocks();

            Message message = new Message(mocks.Session.Object);
            mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(message);
            mocks.ServerBehaviour.Setup(b => b.GetMaximumMessageSize(It.IsAny<IConnection>())).Returns((long?)null);

            int messageLine = 0;
            mocks.Connection.Setup(c => c.ReadLine()).Returns(() => messageData[messageLine++]);

            DataVerb verb = new DataVerb();
            verb.Process(mocks.Connection.Object, new SmtpCommand("DATA"));

            mocks.VerifyWriteResponse(StandardSmtpResponseCode.StartMailInputEndWithDot);
            mocks.VerifyWriteResponse(StandardSmtpResponseCode.OK);

            using (StreamReader dataReader = new StreamReader(message.GetData(), Encoding.ASCII))
            {
                Assert.AreEqual(expectedData, dataReader.ReadToEnd());
            }
        }
开发者ID:LiDamon,项目名称:smtp4dev,代码行数:22,代码来源:DataVerbTests.cs

示例4: SomeUserTalkingHandler

        private void SomeUserTalkingHandler(Message message)
        {
            var voiceData = message.GetData<VoiceData>();
            client.PlaySound(voiceData.GetDataInBytes());
            var userSession = voiceData.UserSession;
            var userVM = FindUser(userSession.ConnectionId);
            if (userVM == null)
            {
                return;
            }

            userVM.BeginTalkingTime = DateTime.Now;
            userVM.IsTalking = true;
        }
开发者ID:BrandonClapp,项目名称:babble,代码行数:14,代码来源:VoiceClientViewModel.cs

示例5: SomeUserDisconnectedHandler

 private void SomeUserDisconnectedHandler(Message message)
 {
     var user = message.GetData<UserSession>();
     foreach (var channel in ChannelTreeViewModel.Channels)
     {
         channel.Users.Remove(channel.Users.FirstOrDefault(u => u.ConnectionId == user.ConnectionId));
     }
     AddActivity(string.Format("{0} Disconnected", user.UserInfo.Username));
 }
开发者ID:BrandonClapp,项目名称:babble,代码行数:9,代码来源:VoiceClientViewModel.cs

示例6: SomeUserConnectedHandler

        private void SomeUserConnectedHandler(Message message)
        {
            var userSession = message.GetData<UserSession>();

            var channel = ChannelTreeViewModel.Channels.FirstOrDefault(c => c.Id == userSession.ChannelId);
            if (channel != null)
            {
                channel.Users.Add(new UserInfoViewModel(userSession));
            }
            AddActivity(string.Format("{0} Connected", userSession.UserInfo.Username));
        }
开发者ID:BrandonClapp,项目名称:babble,代码行数:11,代码来源:VoiceClientViewModel.cs

示例7: SomeUserChattingHandler

 private void SomeUserChattingHandler(Message message)
 {
     var chatData = message.GetData<ChatData>();
     AddActivity("{0}: {1}", chatData.UserSession.UserInfo.Username, chatData.Data);
 }
开发者ID:BrandonClapp,项目名称:babble,代码行数:5,代码来源:VoiceClientViewModel.cs

示例8: SomeUserChangedStatusHandler

        private void SomeUserChangedStatusHandler(Message message)
        {
            var userSession = message.GetData<UserSession>();
            var user = FindUser(userSession.ConnectionId);
            if (user == null)
            {
                return;
            }

            user.UserStatus = userSession.UserStatus;
            AddActivity("{0} changed status to {1}", user.Username, user.UserStatus);
        }
开发者ID:BrandonClapp,项目名称:babble,代码行数:12,代码来源:VoiceClientViewModel.cs

示例9: SomeUserChangedChannelHandler

 private void SomeUserChangedChannelHandler(Message message)
 {
     var userSession = message.GetData<UserSession>();
     var userVM = RemoveUserFromChannels(userSession);
     userVM.ChannelId = userSession.ChannelId;
     AddUserToChannel(userVM);
     AddActivity("{0} joined channel {1}", userSession.UserInfo.Username, userSession.ChannelId);
 }
开发者ID:BrandonClapp,项目名称:babble,代码行数:8,代码来源:VoiceClientViewModel.cs

示例10: RefreshChannelsHandler

 private void RefreshChannelsHandler(Message message)
 {
     var channels = message.GetData<List<ChannelSession>>();
     ChannelTreeViewModel = new ChannelTreeViewModel(channels);
     AddActivity("Ain't nobody dope as me I'm dressed so fresh so clean");
 }
开发者ID:BrandonClapp,项目名称:babble,代码行数:6,代码来源:VoiceClientViewModel.cs

示例11: ChannelRenamedHandler

 private void ChannelRenamedHandler(Message message)
 {
     var channel = message.GetData<Channel>();
     var channelVM = FindChannel(channel.Id);
     channelVM.Name = channel.Name;
     AddActivity("Channel {0} : {1} renamed", channel.Id, channel.Name);
 }
开发者ID:BrandonClapp,项目名称:babble,代码行数:7,代码来源:VoiceClientViewModel.cs

示例12: ChannelDeletedHandler

 private void ChannelDeletedHandler(Message message)
 {
     var channel = message.GetData<Channel>();
     var channelVM = FindChannel(channel.Id);
     ChannelTreeViewModel.Channels.Remove(channelVM);
     AddActivity("Channel {0} : {1} deleted", channel.Id, channel.Name);
 }
开发者ID:BrandonClapp,项目名称:babble,代码行数:7,代码来源:VoiceClientViewModel.cs

示例13: ChannelCreatedHandler

 private void ChannelCreatedHandler(Message message)
 {
     var channelSession = message.GetData<ChannelSession>();
     ChannelTreeViewModel.Channels.Add(new ChannelViewModel(channelSession));
     AddActivity("Channel {0} : {1} created", channelSession.Channel.Id, channelSession.Channel.Name);
 }
开发者ID:BrandonClapp,项目名称:babble,代码行数:6,代码来源:VoiceClientViewModel.cs

示例14: FromMessage

            public static Whisper FromMessage(Message message)
            {
                string whisperContent = message.GetData<string>("message");

                int spacePosition = whisperContent.IndexOf(' ');
                if (spacePosition == -1)
                {
                    return null;
                }

                return new Whisper
                {
                    Username = whisperContent.Substring(0, spacePosition),
                    Message = whisperContent.Substring(spacePosition + 1)
                };
            }
开发者ID:vc3,项目名称:aspComet,代码行数:16,代码来源:Whisperer.cs

示例15: ProcessRegisterProcessMessage

        private void ProcessRegisterProcessMessage(Message message)
        {
            SimpleTableMessageData messageData = MessageServerMessageDataFactory.CreateRegisterProcessData();
            message.GetData(messageData);

            int processID = (int) messageData["Process ID"];
            string targetName = (string) messageData["Target Name"];
            string slotName = (string) messageData["Slot Name"];
            string completionEventName = (string) messageData["Event Name"];

            using (EventWaitHandle completionEvent = new EventWaitHandle(false, EventResetMode.AutoReset, completionEventName))
            {
                if (!_processEntries.Any((entry) => entry.ProcessID == processID))
                {
                    int slotIndex = _messageSlots.AllocateSlot(slotName);

                    MessageServerProcessEntry newProcessEntry = new MessageServerProcessEntry(targetName,
                        processID, slotName, slotIndex);

                    _processEntries.Add(newProcessEntry);
                }

                completionEvent.Set();
            }
        }
开发者ID:gaxar77,项目名称:Tibayan,代码行数:25,代码来源:MessageServer.cs


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