本文整理汇总了C#中bnet.GetNotificationType方法的典型用法代码示例。如果您正苦于以下问题:C# bnet.GetNotificationType方法的具体用法?C# bnet.GetNotificationType怎么用?C# bnet.GetNotificationType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bnet
的用法示例。
在下文中一共展示了bnet.GetNotificationType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendNotification
public override void SendNotification(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.notification.Notification request, Action<bnet.protocol.NoData> done)
{
switch (request.GetNotificationType())
{
case NotificationTypeHelper.NotificationType.Whisper:
// NOTE: Real implementation doesn't even handle the situation where neither client knows about the other.
// Client requires prior knowledge of sender and target (and even then it cannot whisper by using the /whisper command).
Logger.Trace(string.Format("NotificationRequest.Whisper by {0} to {1}", this.Client.CurrentToon, ToonManager.GetToonByLowID(request.TargetId.Low)));
var account = ToonManager.GetOwnerAccountByToonLowId(request.TargetId.Low);
if (account.LoggedInClient == null) return;
if (account is CommandHandlerAccount) // hackish way to enable server commands for players that are not in party.
CommandHandlerAccount.Instance.ParseCommand(request, this.Client);
else
{
var notification = bnet.protocol.notification.Notification.CreateBuilder(request)
.SetSenderId(this.Client.CurrentToon.BnetEntityID)
.Build();
account.LoggedInClient.MakeRPC(() => bnet.protocol.notification.NotificationListener.CreateStub(account.LoggedInClient).
OnNotificationReceived(controller, notification, callback => { }));
}
break;
default:
Logger.Warn("Unhandled notification type: {0}", request.Type);
break;
}
var builder = bnet.protocol.NoData.CreateBuilder();
done(builder.Build());
}
示例2: SendNotification
public override void SendNotification(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.notification.Notification request, Action<bnet.protocol.NoData> done)
{
switch (request.GetNotificationType())
{
case NotificationTypeHelper.NotificationType.Whisper:
// NOTE: Real implementation doesn't even handle the situation where neither client knows about the other.
// Client requires prior knowledge of sender and target (and even then it cannot whisper by using the /whisper command).
Logger.Trace(string.Format("NotificationRequest.Whisper by {0} to {1}", this.Client.CurrentToon, ToonManager.GetToonByLowID(request.TargetId.Low)));
var targetAccount = ToonManager.GetOwnerAccountByToonLowId(request.TargetId.Low);
if (targetAccount.LoggedInClient == null) return;
if (targetAccount == this.Client.Account) // check if whisper targets the account itself.
CommandManager.TryParse(request.AttributeList[0].Value.StringValue, this.Client); // try parsing it as a command and respond it if so.
else
{
var notification = bnet.protocol.notification.Notification.CreateBuilder(request)
.SetSenderId(this.Client.CurrentToon.BnetEntityID)
.Build();
targetAccount.LoggedInClient.MakeRPC(() =>
bnet.protocol.notification.NotificationListener.CreateStub(targetAccount.LoggedInClient).OnNotificationReceived(controller, notification, callback => { }));
}
break;
default:
Logger.Warn("Unhandled notification type: {0}", request.Type);
break;
}
var builder = bnet.protocol.NoData.CreateBuilder();
done(builder.Build());
}
示例3: SendNotification
public override void SendNotification(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.notification.Notification request, Action<bnet.protocol.NoData> done)
{
Logger.Trace("SendNotification()");
//Logger.Debug("notification:\n{0}", request.ToString());
switch (request.GetNotificationType())
{
case NotificationTypeHelper.NotificationType.Whisper:
// NOTE: Real implementation doesn't even handle the situation where neither client knows about the other.
// Client requires prior knowledge of sender and target (and even then it cannot whisper by using the /whisper command).
Logger.Trace(string.Format("NotificationRequest by {0} to {1}", this.Client.CurrentToon, ToonManager.GetToonByLowID(request.TargetId.Low)));
var account = ToonManager.GetOwnerAccountByToonLowId(request.TargetId.Low);
if (account.LoggedInClient == null) return;
var notification = bnet.protocol.notification.Notification.CreateBuilder(request)
.SetSenderId(this.Client.CurrentToon.BnetEntityID)
.Build();
var method = bnet.protocol.notification.NotificationListener.Descriptor.FindMethodByName("OnNotificationReceived");
account.LoggedInClient.CallMethod(method, notification);
break;
default:
Logger.Warn("Unhandled notification type: {0}", request.Type);
break;
}
var builder = bnet.protocol.NoData.CreateBuilder();
done(builder.Build());
}