本文整理汇总了C#中ISender类的典型用法代码示例。如果您正苦于以下问题:C# ISender类的具体用法?C# ISender怎么用?C# ISender使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISender类属于命名空间,在下文中一共展示了ISender类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestPoint
public static void TestPoint(Server server, ISender sender, ArgumentList args)
{
string param;
Player player = server.GetPlayerByName(sender.Name);
if (args.TryGetString(0, out param))
{
switch (param.ToUpper())
{
case "LOBBY":
player.sendMessage("Teleporting to the lobby", Login.plugin.chatColor);
Login.plugin.TeleportPlayerToPoint(player, Login.LOBBY);
break;
case "VALIDATED":
player.sendMessage("Teleporting to the validated point", Login.plugin.chatColor);
Login.plugin.TeleportPlayerToPoint(player, Login.VALIDATED);
break;
default:
player.sendMessage("You must specify either lobby or validated", Login.plugin.chatColor);
break;
}
}
else
player.sendMessage("You must specify either lobby or validated", Login.plugin.chatColor);
}
示例2: DeopPlayer
/// <summary>
/// De-OPs a given Player.
/// </summary>
/// <param name="sender">Sending player</param>
/// <param name="args">Arguments sent with command</param>
public static void DeopPlayer(ISender sender, ArgumentList args)
{
var playerName = args.GetString(0);
Player player;
if (args.TryGetOnlinePlayer(0, out player))
{
playerName = player.Name;
if (Player.isInOpList(playerName))
{
player.sendMessage("You have been De-Opped!.", ChatColor.Green);
}
player.Op = false;
if (player.HasClientMod)
{
NetMessage.SendData(Packet.CLIENT_MOD, player.whoAmi);
}
}
if (Player.isInOpList(playerName))
{
Server.notifyOps("De-Opping " + playerName + " {" + sender.Name + "}", true);
Server.OpList.removeException(playerName + ":" + Player.GetPlayerPassword(playerName));
}
if (!Server.OpList.Save())
{
Server.notifyOps("OpList Failed to Save due. {" + sender.Name + "}", true);
return;
}
}
示例3: HandleData
public void HandleData(MemBlock payload, ISender return_path, object state) {
if(_sub != null) {
MemBlock rest = null;
PType.Parse(payload, out rest);
_sub.Handle(rest, return_path);
}
}
示例4: HandleRpc
// Provides a method for local apps to add certificates to Brunet without
// being loaded with Brunet.
public void HandleRpc(ISender caller, string method, IList args, object rs)
{
object result = null;
try {
if(method.Equals("AddCertificate")) {
ReqrepManager.ReplyState rqrs = caller as ReqrepManager.ReplyState;
if(rqrs == null || !(rqrs.ReturnPath is Node)) {
throw new Exception("Call must be made locally for security reasons!");
}
string path = (string) args[0];
result = _ch.AddCertificate(path);
} else if(method.Equals("GetState")) {
if(args.Count != 1) {
throw new Exception("Not enough arguments");
} else if(!(args[0] is string)) {
throw new Exception("Argument should be a string");
}
Address addr = AddressParser.Parse(args[0] as string);
SecurityAssociation sa = CheckForSecureSender(addr);
if(sa == null) {
result = "No SA";
} else {
result = sa.ToString();
}
} else {
result = new Exception("Invalid method");
}
} catch (Exception e) {
result = e;
}
_node.Rpc.SendResult(rs, result);
}
示例5: DtlsAssociation
/// <summary>Create a DtlsFilter.</summary>
/// <param name="key">A CryptoKey initialized by the OpenSSL.NET library.</param>
/// <param name="cert">The path to the certificate to use.</param>
/// <param name="ca_cert">The path to the ca certificate to use.</param>
/// <param name="client">Use client initialization parameters.</param>
public DtlsAssociation(ISender sender, CertificateHandler ch, PType ptype,
Ssl ssl, bool client) : base(sender, ch)
{
_ip = new IdentifierPair();
PType = ptype;
_ssl = ssl;
_client = client;
_ssl.SetReadAhead(1);
// Buggy SSL versions have issue with compression and dtls
_ssl.SetOptions((int) SslOptions.SSL_OP_NO_COMPRESSION);
if(client) {
_ssl.SetConnectState();
} else {
_ssl.SetAcceptState();
}
// The ssl object will take control
_read = BIO.MemoryBuffer(false);
_read.NonBlocking = true;
_write = BIO.MemoryBuffer(false);
_write.NonBlocking = true;
_ssl.SetBIO(_read, _write);
_ssl.DoHandshake();
_buffer = new byte[Int16.MaxValue];
_buffer_sync = new object();
_fe_lock = 0;
}
示例6: NPCSpawning
/// <summary>
/// Enables or disables NPC spawning
/// </summary>
/// <param name="sender">Sending player</param>
/// <param name="args">Arguments sent with command</param>
public void NPCSpawning(ISender sender, ArgumentList args)
{
args.ParseNone();
Core.StopNPCSpawning = !Core.StopNPCSpawning;
sender.Message("NPC spawning is now " + (Core.StopNPCSpawning ? "off" : "on") + "!");
}
示例7: InstructionPacketSetID
public InstructionPacketSetID(byte servoId, byte newId, ISender sender)
: base(servoId, sender)
{
_instruction = 0x03;
_lengthOfCommand = 0x04;
_parameters.AddRange(new[] { (byte)0x03, newId });
}
示例8: Auth
/// <summary>
/// Allows users to log in.
/// </summary>
/// <param name="sender">Sending player</param>
/// <param name="password">Password for verification</param>
public void Auth(ISender sender, string password)
{
if (sender is Player)
{
var player = sender as Player;
if (Storage.IsAvailable)
{
var existing = Authentication.GetPlayer(sender.SenderName);
if (existing != null)
{
if (existing.ComparePassword(sender.SenderName, password))
{
Utils.NotifyAllOps(
String.Format("{0} successfully logged in.", player.name)
);
player.SendMessage("Successfully logged in.", Color.DarkGreen);
player.SetAuthentication(sender.SenderName, "tdsm");
player.SetOp(existing.Operator);
}
else
{
sender.Message("Login failed", Color.DarkRed);
}
}
else
{
sender.Message("Login failed", Color.DarkRed);
}
}
else
sender.Message("This function is unavailable", Color.DarkRed);
}
}
示例9: Ban
/// <summary>
/// Bans a user from the server.
/// </summary>
/// <param name="sender">Sending entity</param>
/// <param name="args">Arguments sent with command</param>
public static void Ban(ISender sender, string player)
{
if (sender is ConsoleSender)
{
if (String.IsNullOrEmpty(player))
{
Tools.WriteLine("Usage: ban <player>");
}
else
{
bool found = false;
var lowered = player.ToLower();
for (int i = 0; i < 255; i++)
{
if (Main.player[i].active && Main.player[i].name.ToLower() == lowered)
{
Callbacks.NetplayCallback.AddBan(i);
NetMessage.SendData(2, i, -1, "Banned from server.", 0, 0f, 0f, 0f, 0);
found = true;
}
}
if (!found) sender.Message("Failed to find a player by the name of {0}", player);
}
}
}
示例10: Subscribe
public void Subscribe(ISender sender)
{
sender.MessageAvailable += (o, args) =>
{
ReceivedMessage = args.Message;
};
}
示例11: List
/// <summary>
/// Prints a player list, Possibly readable by bots.
/// </summary>
/// <param name="sender">Sending player</param>
/// <param name="args">Arguments sent with command</param>
public void List(ISender sender, ArgumentList args)
{
args.ParseNone();
var players = from p in Terraria.Main.player
where p.active && !p.IsOp()
select p.name;
var ops = from p in Terraria.Main.player
where p.active && p.IsOp()
select p.name;
var pn = players.Count();
var on = ops.Count();
if (on + pn == 0)
{
sender.Message("No players online.");
return;
}
string ps = String.Empty;
string os = String.Empty;
if (pn > 0)
ps = (on > 0 ? " | Players: " : "Players: ") + String.Join(", ", players);
if (on > 0)
os = "Ops: " + String.Join(", ", ops);
sender.SendMessage(string.Concat(os, ps, " (", on + pn, "/", Netplay.MaxConnections, ")"), 255, 255, 240, 20);
}
示例12: TeleportHere
/// <summary>
/// Teleports specified player to sending player's location.
/// </summary>
/// <param name="sender">Sending player</param>
/// <param name="args">Arguments sent with command</param>
public void TeleportHere(ISender sender, ArgumentList args)
{
if (sender is Player)
{
Player player = ((Player)sender);
Player subject;
if (args.TryPopOne(out subject))
{
if (subject == null)
{
sender.Message("Cannot find player");
return;
}
subject.Teleport(player);
Utils.NotifyAllOps("Teleported " + subject.name + " to " +
player.name + " [" + sender.SenderName + "]", true);
}
}
else
{
throw new CommandError("This command is for players only");
}
}
示例13: RequestCommand
public RequestCommand(ISender sender)
{
if (sender == null)
throw new ArgumentNullException("sender");
this.sender = sender;
}
示例14: ChangePassword
void ChangePassword(ISender sender, string password)
{
if (!Storage.IsAvailable)
throw new CommandError("No permissions plugin or data plugin is attached");
var player = sender as Player;
if (player == null)
{
sender.SendMessage("This is a player command", G: 0, B: 0);
return;
}
else if (!player.IsAuthenticated())
{
sender.SendMessage("You are not authenticated.", G: 0, B: 0);
return;
}
else if (password == null || password.Trim().Length < MinPasswordLength)
{
sender.SendMessage("Please specify a password longer than 5 characters.", G: 0, B: 0);
return;
}
var auth = player.GetAuthenticatedAs();
if (Authentication.UpdatePlayer(auth, password))
{
sender.SendMessage("Your password is now updated.", R: 0, B: 0);
}
else
{
sender.SendMessage("Failed to update your password.", G: 0, B: 0);
}
}
示例15: PasswordCommand
void PasswordCommand(ISender sender, ArgumentList args)
{
Player player = sender as Player;
Protection temp = new Protection ();
Pair<Action, Protection> pair = new Pair<Action, Protection> (Action.NOTHING, null);
if (args.Count != 1) {
player.SendMessage ("Usage: /cpassword <password>", 255, 255, 0, 0);
return;
}
string Extra = args[0];
temp = new Protection ();
temp.Owner = player.Name;
temp.Type = Protection.PASSWORD_PROTECTION;
temp.Data = SHA1.Hash (Extra);
char[] pass = Extra.ToCharArray ();
for (int index = 0; index < pass.Length; index++) {
pass [index] = '*';
}
pair.First = Action.CREATE;
pair.Second = temp;
player.SendMessage ("Password: " + new string (pass), 255, 255, 0, 0);
player.SendMessage ("Open the chest to protect it!", 255, 0, 255, 0);
// cache the action if it's not null!
if (pair.First != Action.NOTHING) {
ResetActions (player);
Cache.Actions.Add (player.Name, pair);
}
}