本文整理汇总了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();
}
示例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();
}
}
示例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());
}
}
示例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;
}
示例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));
}
示例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));
}
示例7: SomeUserChattingHandler
private void SomeUserChattingHandler(Message message)
{
var chatData = message.GetData<ChatData>();
AddActivity("{0}: {1}", chatData.UserSession.UserInfo.Username, chatData.Data);
}
示例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);
}
示例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);
}
示例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");
}
示例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);
}
示例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);
}
示例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);
}
示例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)
};
}
示例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();
}
}