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


C# ISession.Send方法代码示例

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


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

示例1: Dispatch

        public void Dispatch(ISession session, IPacket packet)
        {
            BinaryReader reader = packet.CreateReader();
            byte castCount = reader.ReadByte();
            uint spellId = reader.ReadUInt32();
            byte unklags = reader.ReadByte();

            IPacket pkt = WorldPacketFactory.Create(WMSG.SMSG_SPELL_START);
            BinaryWriter writer = pkt.CreateWriter();
            writer.WritePackGuid(session.Player.Guid);
            writer.WritePackGuid(session.Player.Guid);
            writer.Write(castCount);
            writer.Write(spellId);
            writer.Write(0); //cast flags
            writer.Write(0); //ticks count
            writer.Write(0); //targetflags
            session.Send(pkt);

            Thread.Sleep(5000);
            pkt = WorldPacketFactory.Create(WMSG.SMSG_SPELL_GO);
            writer = pkt.CreateWriter();
            writer.WritePackGuid(session.Player.Guid);
            writer.WritePackGuid(session.Player.Guid);
            writer.Write(castCount);
            writer.Write(spellId);
            writer.Write(0); //cast flags
            writer.Write(0); //ticks count
            writer.Write((byte)1); //hit count
            writer.Write(session.Player.Guid);
            writer.Write((byte)0); //miss count
            writer.Write(0); // targetflags
            session.Send(pkt);
        }
开发者ID:hazzik,项目名称:uwow2,代码行数:33,代码来源:CastSpellDispatcher.cs

示例2: Dispatch

        public void Dispatch(ISession session, IPacket packet)
        {
            BinaryReader reader = packet.CreateReader();
            int guildId = reader.ReadInt32();
            var guild = new Guild
                            {
                                Id = guildId,
                                Name = "guild"
                            };

            IPacketBuilder responce = WorldPacketFactory.Build(
                WMSG.SMSG_GUILD_QUERY_RESPONSE,
                writer =>
                    {
                        writer.Write(guild.Id);
                        writer.WriteCString(guild.Name);
                        foreach (GuildRank rank in guild.Ranks)
                            writer.WriteCString(rank.Name);
                        for (int i = 0; i < 10 - guild.Ranks.Count; i++)
                            writer.WriteCString(string.Empty);
                        writer.Write(guild.Tabard.EmblemStyle);
                        writer.Write(guild.Tabard.EmblemColor);
                        writer.Write(guild.Tabard.BorderStyle);
                        writer.Write(guild.Tabard.BorderColor);
                        writer.Write(guild.Tabard.BackgroundColor);
                        writer.Write(0); // NEW 3.0.2
                    });
            session.Send(responce);
        }
开发者ID:hazzik,项目名称:uwow2,代码行数:29,代码来源:GuildQuery.cs

示例3: Dispatch

        public void Dispatch(ISession session, IPacket packet)
        {
            BinaryReader reader = packet.CreateReader();
            var type = (AccountDataType)reader.ReadUInt32();
            ulong guid = session.Player != null ? session.Player.Guid : 0;

            AccpuntData accpuntData = session.Account.FindAccpuntData(type, guid);

            session.Send(GetUpdateAccountDataPkt(accpuntData));
        }
开发者ID:hazzik,项目名称:uwow2,代码行数:10,代码来源:RequestAccountDataDispatcher.cs

示例4: Deserialize

        public IEnumerable<IMessage> Deserialize(ISession session, byte[] data)
        {
            Deserializer deserializer = new Deserializer(data);

            while (deserializer.BaseStream.Position < deserializer.BaseStream.Length)
            {
                byte header = deserializer.ReadByte();
                byte length = deserializer.ReadByte();

                switch (length)
                {
                    case 0x05: // Version
                        deserializer.BaseStream.Position += 2;
                        /*this.clientVersion = */deserializer.ReadUInt32();
                        deserializer.BaseStream.Position += 56; // Probably wrong offset
                        break;

                    case 0x42: // PublicKey
                        byte[] publicKey = deserializer.ReadBytes(64);
                        byte[] sharedKey = DiffieHellman.GenerateSharedKey(publicKey, Keys.PrivateKey, Keys.Prime);
                        byte[] randomBytes = CryptoUtils.GetRandomBytes();
                        byte[] hashedRandomBytes = CryptoUtils.Hash(randomBytes);
                        byte[] xoredRandomBytes = CryptoUtils.XOR(randomBytes, sharedKey);
                        this.key = hashedRandomBytes;

                        Serializer serializer = new Serializer();
                        serializer.Write((byte)0x01); // RC4Seed Header
                        serializer.Write((byte)0x16); // RC4Seed Length
                        serializer.Write(xoredRandomBytes); // xored RC4Key

                        session.Send(serializer.GetBytes());

                        session.State = prepareNewState();

                        break;

                    default:
                        Console.WriteLine("Unhandled packet, header: {0}, length: {1}", header, length);
                        break;
                }
            }

            // mock up, since we return the byte-encoded messages directly
            return new IMessage[] {};
        }
开发者ID:puppt,项目名称:GW2Emu,代码行数:45,代码来源:HandshakeState.cs

示例5: Dispatch

        public void Dispatch(ISession session, IPacket packet)
        {
            BinaryReader reader = packet.CreateReader();
            var type = (AccountDataType)reader.ReadUInt32();
            DateTime time = DateTimeExtension.ToDateTime(reader.ReadUInt32());
            var decompressedSize = reader.ReadInt32();
            reader = new BinaryReader(new InflaterInputStream(reader.BaseStream));
            string data = Encoding.UTF8.GetString(reader.ReadBytes(decompressedSize));

            var ad = new AccpuntData {
                //Guid =
                Type = type,
                Time = time,
                Data = data,
            };

            session.Account.SetAccountData(ad);
            session.Send(GetUpdateAccountDataCompletePkt(type));
        }
开发者ID:hazzik,项目名称:uwow2,代码行数:19,代码来源:UpdateAccountDataDispatcher.cs

示例6: PublicMessage

        /// <summary>
        /// NOTE: we don't need an app-level ack for this method :-)
        /// </summary>
        public void PublicMessage(ISession session, PublicMessageRequest msgRequest)
        {
            if (session.User.IsDevoiced)
            {
                session.Send(new YouAreDevoicedNotification());
                return;
            }

            PublicMessage message = null;
            using (var uow = UnitOfWorkFactory.Create())
            {
                uow.Attach(session.User);
                message = new PublicMessage(session.User, msgRequest.Body);
                uow.PublicMessageRepository.Add(message);
                uow.Commit();
            }

            var dto = message.ProjectedAs<PublicMessageDto>();
            dto.Role = (UserRoleEnum)(int)session.User.Role;
            _sessionManager.SendToEachChatSessions(dto);
        }
开发者ID:jorik041,项目名称:CrossChat,代码行数:24,代码来源:ChatService.cs

示例7: SendImage

        public SendImageResponse SendImage(ISession session, SendImageRequest request)
        {
            var response = request.CreateResponse<SendImageResponse>();
            response.ImageId = -1;

            if (session.User.IsDevoiced)
            {
                session.Send(new YouAreDevoicedNotification());
                return response;
            }

            PublicMessage message = null;
            using (var uow = UnitOfWorkFactory.Create())
            {
                int fileId;
                try
                {
                    fileId = _fileStorage.AppendFile(request.Image);
                    response.ImageId = fileId;
                }
                catch (System.Exception)
                {
                    //Invalid image
                    return response;
                }
                uow.Attach(session.User);
                message = new PublicMessage(session.User, fileId, "Your client doesn't support IMAGE messages");
                uow.PublicMessageRepository.Add(message);
                uow.Commit();
            }

            var dto = message.ProjectedAs<PublicMessageDto>();
            dto.Role = (UserRoleEnum)(int)session.User.Role;
            _sessionManager.SendToEachChatSessions(dto);
            return response;
        }
开发者ID:CodeFork,项目名称:CrossChat-Xamarin.Forms,代码行数:36,代码来源:ChatService.cs

示例8: Dispatch

 public void Dispatch(ISession session, IPacket packet)
 {
     session.Send(GetPongPkt(packet.CreateReader().ReadUInt32()));
 }
开发者ID:hazzik,项目名称:uwow2,代码行数:4,代码来源:PingDispatcher.cs

示例9: Dispatch

 public void Dispatch(ISession session, IPacket packet)
 {
     IPacket pkt = GetCorpseQuery(session.Player.Corpse);
     session.Send(pkt);
 }
开发者ID:hazzik,项目名称:uwow2,代码行数:5,代码来源:CorpseQuery.cs


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