本文整理汇总了C#中IMessageClient.Send方法的典型用法代码示例。如果您正苦于以下问题:C# IMessageClient.Send方法的具体用法?C# IMessageClient.Send怎么用?C# IMessageClient.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMessageClient
的用法示例。
在下文中一共展示了IMessageClient.Send方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PageUser
public void PageUser(Message message, IMessageClient client, string name)
{
string regex = string.Format("(.*)({0})(.*)", name);
List<IEntity> rooms = client.GetAllRooms().ToList();
string sentFrom = client.GetUser(message.UserId).Name;
IEntity requestedRoom = rooms.Single(r => r.Id == message.RoomId);
const string pageMessage = "Paging {0} ... Paging {0} ... Your presence is requested by {1} in the \"{2}\" room.";
const string failureMessage = "Sorry, nobody by the name {0} could be found.";
const string userIsInYourRoom = "Lulz!! {0} is in your room.";
var roomsUserIsIn = new List<IEntity>();
bool hasMatch = false;
foreach (IEntity room in rooms)
{
IEnumerable<IEntity> usersInRoom = client.GetUsersInRoom(room.Id);
foreach (IEntity user in usersInRoom)
{
if (Regex.IsMatch(user.Name, regex, RegexOptions.IgnoreCase))
{
roomsUserIsIn.Add(room);
string response = string.Format(pageMessage, user.Name, sentFrom, requestedRoom.Name);
if (room.Id == requestedRoom.Id)
response = string.Format(userIsInYourRoom, user.Name);
client.Send(response, room.Id);
hasMatch = true;
}
}
}
if (!hasMatch)
{
string response = string.Format(failureMessage, name);
client.Send(response, requestedRoom.Id);
}
else
{
var responseMessage = new StringBuilder();
responseMessage.AppendLine(string.Format("{0}, \"{1}\" was found in the following rooms:", sentFrom, name));
foreach (IEntity room in roomsUserIsIn)
{
responseMessage.AppendLine(string.Format("- {0}", room.Name));
}
client.Send(responseMessage.ToString(), requestedRoom.Id);
}
}
示例2: HandleTemperatureRequest
public async void HandleTemperatureRequest(IMessageClient client, TemperatureRequest request)
{
await Context;
var temp = await service.GetTemperature(request.City);
client.Send(new TemperatureResponse
{
City = request.City,
Temperature = temp,
});
}
示例3: DoIsItDownForYou
public void DoIsItDownForYou(Message message, IMessageClient client, string site)
{
try
{
IRestClient jsonClient = GetJsonServiceClient(DownForMeSite);
var result = jsonClient.Get<string>(site);
Match match = Regex.Match(result, SiteIsUpReges);
client.ReplyTo(message, match.Success ? string.Format("It's just you. {0} is up for me.", site) : string.Format("Oh no {0} is down for me too!!!!! *PANIC*", site));
}
catch (Exception e)
{
client.Send("Oh no I am Down!!! *UberPanic*", message.RoomId);
}
}
示例4: HandleMessaeg
public void HandleMessaeg(Message message, IMessageClient client, string input)
{
client.Send(input, message.RoomId);
}