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


C# Client.Send方法代码示例

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


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

示例1: LearnSkill

        public static void LearnSkill(Client client, PacketIn packet)
        {
            byte skillId = packet.ReadByte();
            if(client.Character.Player.SkillPoints >= 1)
            {
                if(!client.Character.Skills.ContainsKey(skillId))
                {
                    using(ISession session = Server.Factory.OpenSession())
                    {
                        PlayerSkill skill = new PlayerSkill();
                        skill.Level       = 1;
                        skill.PlayerId    = client.Character.Player.PlayerId;
                        skill.SkillIndex  = (int)skillId;

                        client.Character.Skills[skillId] = skill;
                        client.Send(new Packets.SkillSet(skillId,(byte)1));

                        using(ITransaction transaction = session.BeginTransaction())
                        {
                            session.Save(skill);
                            transaction.Commit();
                        }
                    }
                    client.Character.Player.SkillPoints--;
                    client.Send(new Packets.ValueChange(0x18,(byte)client.Character.Player.SkillPoints));
                }
            }
        }
开发者ID:KalOnline,项目名称:KaLua,代码行数:28,代码来源:PT_Skill.cs

示例2: Execute

        public override void Execute(Server server, Client client, string args)
        {
            args = args.ToLowerInvariant();

            //if (Win32Window.GetForegroundWindow() != WindowHandle) {
                Win32Window.SetForegroundWindow(WindowHandle);
            //}

            ButtonClickFn clickFn = null;

            switch (args) {
                case "left":  clickFn = Win32Input.LeftClick; break;
                case "right": clickFn = Win32Input.RightClick; break;
                default:
                    client.Send("Error: invalid button");
                    return;
            }

            if (!clickFn()) {
                client.Send("Error: {0}() returned false", clickFn.Method.Name);
                return;
            }

            client.Send(); // TODO determine if glider sent anything back
        }
开发者ID:timglide,项目名称:hb-plugins,代码行数:25,代码来源:ClickMouse.cs

示例3: DropItem

        public static void DropItem(Client client, PacketIn packet)
        {
            int itemId      = (int)packet.ReadUInt32();
            PlayerItem item = PlayerItem.Get(itemId);
            int quantity    = (int)packet.ReadUInt32();

            if(item == null) {
                ServerConsole.WriteLine(
                    "Player #{0} attempted to drop non-existant item #{1} !",
                    client.Character.Player.PlayerId,
                    itemId
                );
                return;
            }

            if(item.PlayerId != client.Character.Player.PlayerId) {
                ServerConsole.WriteLine(
                    "Player #{0} attempted to drop item that belongs to #{1}!",
                    client.Character.Player.PlayerId,
                    item.PlayerId
                );
                return;
            }

            uint worldId = World.NewId();
            Server.WorldDrops[worldId] = new Drop(item,client.Character,quantity,worldId);

            client.Send(new Packets.SpawnDrop(Server.WorldDrops[worldId]),"Spawn Drop");
            client.Send(new Packets.RemoveFromInventory(item.ItemId,quantity),"Update Inventory");
            client.Character.Player.Inventory.Items.Remove(item);
        }
开发者ID:KalOnline,项目名称:KaLua,代码行数:31,代码来源:PT_Item.cs

示例4: Execute

        public override void Execute(Server server, Client client, string args)
        {
            if ("" == args) {
                client.Send();
                return;
            }

            // see if this is a JGlideMon style chat command, JGM added manually
            // pressing enter before and after

            if (args.StartsWith("#13#/")) {
                args = args.Substring(4); // remove leading #13#

                if (args.EndsWith("#13#")) {
                    args = args.Substring(0, args.Length - 4); // remove trailing #13#
                }
            }

            if (VKRegex.IsMatch(args)) {
                // ignore anything that requires sending VK codes
            } else if (args.StartsWith("/")) {
                // escape so it's a valid Lua string (order of replacement is important)
                args = args.Replace("\\", "\\\\").Replace("\"", "\\\"");
                args = string.Format("RunMacroText(\"{0}\")", args);
                Lua.DoString(args, 0);
            } else {
                // ignore anything that isn't a slash command
            }

            client.Send();
        }
开发者ID:timglide,项目名称:GliderRemoteCompat,代码行数:31,代码来源:QueueKeys.cs

示例5: CreateClan

        public static void CreateClan(Client.GameState client)
        {
            try
            {
                uint clanid = Program.nextClanid;
                Program.nextClanid++;
                client.Entity.Myclan.ClanId = clanid;
                MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT);
                cmd.Insert("Clans").Insert("Name", client.Entity.Myclan.ClanName).Insert("ClanID", clanid)
                    .Insert("Leader", client.Entity.Name).Insert("Fund", 500000).Execute();

                MySqlCommand cmd3 = new MySqlCommand(MySqlCommandType.UPDATE);
                cmd3.Update("entities").Set("ClanId", clanid).Set("ClanRank", "100")
                    .Set("ClanDonation", "500000").Where("UID", client.Entity.UID).Execute();
                client.Entity.ClanRank = 100;
                client.Entity.ClanName = client.Entity.Myclan.ClanName;
                client.Entity.ClanId = clanid;
                Network.GamePackets.Clan cl = new PhoenixProject.Network.GamePackets.Clan(client, 1);
                client.Send(cl.ToArray());
                PhoenixProject.ServerBase.Kernel.ServerClans.Add(clanid, client.Entity.Myclan);
                Network.GamePackets.Clan cls = new PhoenixProject.Network.GamePackets.Clan(client, 1);
                client.Send(cls.ToArray());
            }
            catch (Exception e)
            {
                Program.SaveException(e);
            }
        }
开发者ID:Mromany,项目名称:Conquista5679-TheHunterSource-,代码行数:28,代码来源:ClanTable.cs

示例6: Execute

        public override void Execute(Server server, Client client, string args)
        {
            if ("" == args) {
                client.Send();
                return;
            }

            List<string> retValues = Lua.GetReturnValues(args);
            client.Send(retValues);
        }
开发者ID:timglide,项目名称:GliderRemoteCompat,代码行数:10,代码来源:RunLua.cs

示例7: Execute

        public override void Execute(Server server, Client client, string args)
        {
            if (!TreeRoot.IsRunning) {
                client.Send("Already stopped");
                return;
            }

            TreeRoot.Stop();
            client.Send("Glider stopped");
        }
开发者ID:timglide,项目名称:GliderRemoteCompat,代码行数:10,代码来源:StopGlide.cs

示例8: Handle

        public static void Handle(byte[] Data, Client.GameState Client)
        {
            QuestInfoPacket info = new QuestInfoPacket(8);
            ushort num = BitConverter.ToUInt16(Data, 4);
            if (num == 3)
            {
                MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
                cmd.Select("heroquests").Where("hero", Client.Entity.UID).And("quest", 0xb71b2);
                PhoenixProject.Database.MySqlReader reader = new PhoenixProject.Database.MySqlReader(cmd);
                if (Client != null)
                {
                    info.Type = 3;
                    while (reader.Read())
                    {
                        info.AddQuest(reader.ReadUInt32("quest"), (QuestCompleteTypes)((ushort)reader.ReadUInt32("completeflag")));
                        HeroQuest quest2 = new HeroQuest
                        {
                            Identifier = reader.ReadUInt32("quest"),
                            DailyFinishes =  reader.ReadUInt32("dailyfinishes"),
                            CompleteFlag = (QuestCompleteTypes)((ushort) reader.ReadUInt32("completeflag"))
                        };
                        DateTime time3 = new DateTime(0x7b2, 1, 1);
                        quest2.CompleteTime = time3.ToLocalTime().AddSeconds(reader.ReadUInt32("completetime"));

                       // quest2.CompleteTime = new DateTime().FromUnix(Convert.ToUInt32(reader["completetime"]));
                        quest2.Step = reader.ReadUInt32("step");
                        HeroQuest quest = quest2;
                        Client.Quests.GetOrAdd(quest.Identifier, quest);
                    }
                    reader.Close();
                    reader.Dispose();
                }
                Client.Send((byte[])info);
                if (Client != null)
                {
                    cmd.Select("killtargets").Where("hero", Client.Entity.UID);
                    while (reader.Read())
                    {
                        QuestQuery query = new QuestQuery
                        {
                            Identifier = reader.ReadUInt32("quest"),
                            Unknown2 = reader.ReadUInt32("count")
                        };
                        Client.Send((byte[])query);
                    }
                    reader.Close();
                    reader.Dispose();
                }
            }
            else
            {
                Console.WriteLine("Unhandled QuestInfo (1134) Type "+num+"");
            }
        }
开发者ID:Mromany,项目名称:Conquista5679-TheHunterSource-,代码行数:54,代码来源:QuestInfo.cs

示例9: Execute

        public override void Execute(Server server, Client client, string args)
        {
            try {
                if ("" != args) {
                    client.settings.SetLogState(args, false);
                    client.UpdateLogSettings();
                }

                client.Send("Log: " + client.FormattedLogChannels);
            } catch (ArgumentException x) {
                client.Send("Error: " + x.Message);
            }
        }
开发者ID:timglide,项目名称:GliderRemoteCompat,代码行数:13,代码来源:NoLog.cs

示例10: Execute

        public override void Execute(Server server, Client client, string args)
        {
            try {
                if ("" != args) {
                    client.settings.CaptureScale = int.Parse(args);
                }

                client.Send("Scale set: " + (int)Math.Round(client.settings.CaptureScale * 100));
            } catch (FormatException x) {
                client.Send("Error: " + x.Message);
            } catch (ArgumentException x) {
                client.Send("Error: " + x.Message);
            }
        }
开发者ID:timglide,项目名称:GliderRemoteCompat,代码行数:14,代码来源:CaptureScale.cs

示例11: Main

        static void Main(string[] args)
        {
            // Create the NetMQ context
            using (var context = NetMQContext.Create())
            {
                // Setup a default message factory
                var messageFactory = new MessageFactory();

                // Setup a message handler and register two request handlers
                var messageHandler =
                    RequestDispatcher.Create()
                        .Register<EchoRequest, EchoResponse>(new EchoRequestHandler())
                        .Register<QuadraticRequest, QuadraticResponse>(new QuadraticRequestHandler());

                // Create the server and client
                Server server = new Server(new NetMQReceiverManager(context, "tcp://127.0.0.1:5556"), messageFactory, messageHandler, "ExampleServer");
                Client client = new Client(new NetMQSenderManager(context, "tcp://127.0.0.1:5556"), messageFactory);

                // Run the server in a task with a cancellation token to cancel the task later
                var cancellationTokenSource = new CancellationTokenSource();
                Task.Run(() => server.Run(cancellationTokenSource.Token));


                // Make some requests from the server
                var echo1 = new EchoRequest() { Name = "Jon", Message = "My first message!" };
                var echo2 = client.Send<EchoResponse, EchoRequest>(echo1);
                Display(echo1);
                Display(echo2);

                var echo3 = new EchoRequest() { Name = "Steve", Message = "Hi, I am steve" };
                var echo4 = client.Send<EchoResponse, EchoRequest>(echo3);
                Display(echo3);
                Display(echo4);

                var quad1 = new QuadraticRequest() { A = 1, B = 2, C = 3 };
                var quad2 = client.Send<QuadraticResponse, QuadraticRequest>(quad1);
                Display(quad1);
                Display(quad2);

                var quad3 = new QuadraticRequest() { A = -1, B = 5, C = 4 };
                var quad4 = client.Send<QuadraticResponse, QuadraticRequest>(quad3);
                Display(quad3);
                Display(quad4);


                // Stop the server
                cancellationTokenSource.Cancel();
            }
        }
开发者ID:yonglehou,项目名称:Smoke,代码行数:49,代码来源:Program.cs

示例12: Main

        static void Main(string[] args)
        {
            //Settings
            const string serverIp = "192.168.1.1";
            const string serverSecret = "secretsecretsecret";
            const string userName = "user";
            const string password = "123456";
            const string nasIp = "192.168.20.1";
            const string clientIp = "192.168.20.45";
            const string sessionId = "1234567899874654321";

            var radiusClient = new Client(serverIp, 1645, serverSecret)
                                   {
                                       SendTimeout = 5000,
                                       ReceiveTimeout = 5000,
                                       Ttl = 50
                                   };

            var request = new AccessRequest(nasIp, ServiceType.Framed, userName, password, radiusClient);
            request.Packet.Attributes.Add(new StringAttribute(AttributeType.NasIdentifier, "BBSM"));
            request.Packet.Attributes.Add(new NasPortTypeAttribute(NasPortType.Ethernet));
            request.Packet.Attributes.Add(new StringAttribute(AttributeType.AcctSessionId, sessionId));
            request.Packet.Attributes.Add(new IpAddressAttribute(AttributeType.FramedIpAddress, clientIp));
            var response = radiusClient.Send(request, true);

            var accountingStartRequest = new AccountingRequest(nasIp, ServiceType.Framed, userName, AuthenticationType.Radius,
                                                          StatusType.Start, 0, clientIp, sessionId, radiusClient);
            request.Packet.Attributes.Add(new StringAttribute(AttributeType.NasIdentifier, "BBSM"));
            request.Packet.Attributes.Add(new NasPortTypeAttribute(NasPortType.Ethernet));
            var accountingStartResponse = radiusClient.Send(accountingStartRequest, true);

            var accountingUpdateRequest = new AccountingRequest(nasIp, ServiceType.Framed, userName, AuthenticationType.Radius,
                                    StatusType.InterimUpdate, 0, clientIp, sessionId, radiusClient);
            request.Packet.Attributes.Add(new StringAttribute(AttributeType.NasIdentifier, "BBSM"));
            request.Packet.Attributes.Add(new IntegerAttribute(AttributeType.AcctInputOctets, 5000));
            request.Packet.Attributes.Add(new IntegerAttribute(AttributeType.AcctOutputOctets, 2000));
            request.Packet.Attributes.Add(new IntegerAttribute(AttributeType.AcctSessionTime, 50));
            var accountingUpdateResponse = radiusClient.Send(accountingUpdateRequest, true);

            var accountingStopRequest = new AccountingRequest(nasIp, ServiceType.Framed, userName, AuthenticationType.Radius,
                                    StatusType.Stop, 0, clientIp, sessionId, radiusClient);
            request.Packet.Attributes.Add(new StringAttribute(AttributeType.NasIdentifier, "BBSM"));
            request.Packet.Attributes.Add(new NasPortTypeAttribute(NasPortType.Ethernet));
            request.Packet.Attributes.Add(new IntegerAttribute(AttributeType.AcctInputOctets, 40000));
            request.Packet.Attributes.Add(new IntegerAttribute(AttributeType.AcctOutputOctets, 20000));
            request.Packet.Attributes.Add(new IntegerAttribute(AttributeType.AcctSessionTime, 200));
            request.Packet.Attributes.Add(new TerminateCauseAttribute(TerminateCauseType.UserRequest));
            var accountingStopResponse = radiusClient.Send(accountingStopRequest, true);
        }
开发者ID:OlegUA,项目名称:dotnet-radius-client-library,代码行数:49,代码来源:Program.cs

示例13: Execute

        public override void Execute(Server server, Client client, string args)
        {
            ObjectManager.Update();
            LocalPlayer me = StyxWoW.Me;

            if (null == me || !me.IsValid)
            {
                client.Send("Error: me is null or invalid");
                return;
            }

            WoWBagSlot? slotArg = null;

            try {
                slotArg = (WoWBagSlot) Enum.Parse(typeof(WoWBagSlot), args, true);
            } catch { }

            List<string> l = new List<string>();

            using (StyxWoW.Memory.AcquireFrame()) {
                WoWPlayerInventory inv = me.Inventory;

                if (null != slotArg) {
                    AddContainer(l, me.GetBag(slotArg.Value));
                } else if ("backpack".Equals(args, StringComparison.InvariantCultureIgnoreCase)) {
                    AddItems(l, 0, inv.Backpack);
                } else if ("equipped".Equals(args, StringComparison.InvariantCultureIgnoreCase)) {
                    AddEquipped(l, inv.Equipped);
                } else if ("bags".Equals(args, StringComparison.InvariantCultureIgnoreCase)) {
                    AddItems(l, 0, inv.Backpack);
                    AddContainer(l, me.GetBag(WoWBagSlot.Bag1));
                    AddContainer(l, me.GetBag(WoWBagSlot.Bag2));
                    AddContainer(l, me.GetBag(WoWBagSlot.Bag3));
                    AddContainer(l, me.GetBag(WoWBagSlot.Bag4));
                } else if ("".Equals(args)) {
                    AddEquipped(l, inv.Equipped);
                    AddItems(l, 0, inv.Backpack);
                    AddContainer(l, me.GetBag(WoWBagSlot.Bag1));
                    AddContainer(l, me.GetBag(WoWBagSlot.Bag2));
                    AddContainer(l, me.GetBag(WoWBagSlot.Bag3));
                    AddContainer(l, me.GetBag(WoWBagSlot.Bag4));
                } else {
                    l.Add("Error: invalid slot");
                }
            }

            client.Send(l);
        }
开发者ID:timglide,项目名称:GliderRemoteCompat,代码行数:48,代码来源:Inventory.cs

示例14: SendPacket

        /// <summary>
        /// 
        /// </summary>
        /// <param name="client"></param>
        /// <param name="ServerSalt"></param>
        public void SendPacket(Client client, out string ServerSalt)
        {
            byte[] Packet = new byte[]
            {
                0xDF, 0xDF,
                0x00, 0x01,
                0x00, 0x01,
                0x00, 0x34, // Total Length of Packet 
                0x00, 0x00, 0x00, 0x01,
                0x00, 0x00, 0x2B, 0x3F,
                0x00, 0x00, 0x00, 0x24, // Packet Type (SaltAuthentication)
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Server Salt (32 Bytes)
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
            };

            byte[] Salt = new byte[0x20];
            Random rand = new Random();

            rand.NextBytes(Salt);

            ServerSalt = string.Empty;

            for (int i = 0; i < 32; i++)
            {
                if (Salt[i] == 0) // 0x00 Breaks Things
                    Salt[i] = 42; // So we change it to something nicer
                Packet[20 + i] = Salt[i];

                ServerSalt += String.Format("{0:x2}", Salt[i]);
            }

            client.Send(ref Packet);
        }
开发者ID:gordonc64,项目名称:CellAO-Archived-Obsolete,代码行数:40,代码来源:SaltAuthentication.cs

示例15: EquipItem

 public static void EquipItem(Client client, PacketIn packet)
 {
     int itemId = (int)packet.ReadUInt32();
     PlayerItem item = PlayerItem.Get(itemId);
     if(item == null) {
         ServerConsole.WriteLine(
             System.Drawing.Color.Red,
             "Player #{0} attempted to equip non-existant item!",
             client.Character.Player.PlayerId
         );
         return;
     }
     if(item.PlayerId != client.Character.Player.PlayerId) {
         ServerConsole.WriteLine(System.Drawing.Color.Red,
             "Player #{0} attempted to equip item that belongs to #{1}!",
             client.Character.Player.PlayerId,
             item.PlayerId
         );
         return;
     }
     if(!item.Wearable) {
         ServerConsole.WriteLine(
             System.Drawing.Color.Red,
             "Player #{0} attempted to equip non-equipable item #{1}!",
             item.PlayerId,item.ItemId
         );
         return;
     }
     PlayerItem.Equip(item);
     client.Send(new Packets.EquipItem(item),"Equip Item");
 }
开发者ID:KalOnline,项目名称:KaLua,代码行数:31,代码来源:PT_Item.cs


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