本文整理汇总了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);
}
示例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);
}
示例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));
}
示例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[] {};
}
示例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));
}
示例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);
}
示例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;
}
示例8: Dispatch
public void Dispatch(ISession session, IPacket packet)
{
session.Send(GetPongPkt(packet.CreateReader().ReadUInt32()));
}
示例9: Dispatch
public void Dispatch(ISession session, IPacket packet)
{
IPacket pkt = GetCorpseQuery(session.Player.Corpse);
session.Send(pkt);
}