本文整理汇总了C#中SharpTibiaProxy.Network.InMessage类的典型用法代码示例。如果您正苦于以下问题:C# InMessage类的具体用法?C# InMessage怎么用?C# InMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InMessage类属于SharpTibiaProxy.Network命名空间,在下文中一共展示了InMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseClientSay
private void ParseClientSay(InMessage message)
{
string receiver = null;
ushort channelId = 0;
MessageClasses type = (MessageClasses)message.ReadByte();
switch (type)
{
case MessageClasses.PRIVATE_TO:
case MessageClasses.GAMEMASTER_PRIVATE_TO:
receiver = message.ReadString();
break;
case MessageClasses.CHANNEL:
case MessageClasses.CHANNEL_HIGHLIGHT:
case MessageClasses.GAMEMASTER_CHANNEL:
channelId = message.ReadUShort();
break;
default:
break;
}
string text = message.ReadString();
client.Chat.OnPlayerSpeak(receiver, channelId, type, text);
}
示例2: Enable
public void Enable()
{
client.Rsa = Constants.RSAKey.OpenTibiaM;
loginClientPort = GetFreePort();
worldClientPort = GetFreePort(loginClientPort + 1);
if (!client.IsOpenTibiaServer && client.LoginServers[0].Server == "127.0.0.1")
loginServers = Client.DefaultServers;
else
loginServers = client.LoginServers;
client.LoginServers = new LoginServer[] { new LoginServer("127.0.0.1", loginClientPort) };
if (client.Version.Number == ClientVersion.Version1011.Number)
Util.Memory.WriteBytes(client.ProcessHandle, client.MemoryAddresses.ClientProxyCheckFunctionPointer, client.MemoryAddresses.ClientProxyCheckFunctionNOP, 15);
clientInMessage = new InMessage();
clientOutMessage = new OutMessage();
serverInMessage = new InMessage();
serverOutMessage = new OutMessage();
StartListen();
}
示例3: Connection
public Connection(Socket socket, OtItems items)
{
this.socket = socket;
this.items = items;
message = new InMessage();
map = new OtMap(items);
BeginReceive();
}
示例4: OpenTibiaDecrypt
public static void OpenTibiaDecrypt(InMessage msg)
{
if (msg.Size - msg.ReadPosition != 128)
throw new Exception("Invalid message size.");
var decrypted = openTibiaDecryptEngine.ProcessBlock(msg.Buffer, msg.ReadPosition, 128);
var padSize = 128 - decrypted.Length;
if (padSize > 0)
Array.Clear(msg.Buffer, msg.ReadPosition, padSize);
else
padSize = 0;
Array.Copy(decrypted, 0, msg.Buffer, msg.ReadPosition + padSize, decrypted.Length);
if (msg.ReadByte() != 0)
throw new Exception("Invalid decrypted message.");
msg.Encrypted = false;
}
示例5: ParseClientMessage
public void ParseClientMessage(InMessage message)
{
var packetStart = 0;
try
{
packetStart = message.ReadPosition;
byte cmd = message.ReadByte();
switch (cmd)
{
case 0x96:
ParseClientSay(message);
break;
}
}
catch (Exception ex)
{
Trace.TraceWarning(ex.Message + "\nPacket Bytes: " + message.Buffer.ToHexString(packetStart, message.ReadPosition - packetStart));
}
}
示例6: Enable
public void Enable()
{
client.Rsa = Constants.RSAKey.OpenTibiaM;
loginClientPort = GetFreePort();
worldClientPort = GetFreePort(loginClientPort + 1);
if (!client.IsOpenTibiaServer && client.LoginServers[0].Server == "localhost")
loginServers = Client.DefaultServers;
else
loginServers = client.LoginServers;
client.LoginServers = new LoginServer[] { new LoginServer("localhost", loginClientPort) };
clientInMessage = new InMessage();
clientOutMessage = new OutMessage();
serverInMessage = new InMessage();
serverOutMessage = new OutMessage();
StartListen();
}
示例7: Decrypt
/// <summary>
/// Decrypts the message
/// </summary>
/// <param name="msg">The message to be dencrypted.</param>
/// <param name="key">The key to be used.</param>
public static unsafe void Decrypt(InMessage msg, uint[] key)
{
if (msg == null)
throw new Exception("Null message.");
if (key == null)
throw new Exception("Null key.");
if (!msg.Encrypted)
throw new Exception("Can't dencrypt a dencrypted message.");
var msgSize = msg.Size - 6;
if (msg.Size <= 6 || msgSize % 8 > 0)
throw new Exception("Wrong message size.");
fixed (byte* bufferPtr = msg.Buffer)
{
var words = (uint*)(bufferPtr + 6);
for (var pos = 0; pos < msgSize / 4; pos += 2)
{
var count = 32;
var sum = 0xC6EF3720;
while (count-- > 0)
{
words[pos + 1] -= (words[pos] << 4 ^ words[pos] >> 5) + words[pos] ^ sum
+ key[sum >> 11 & 3];
sum -= DELTA;
words[pos] -= (words[pos + 1] << 4 ^ words[pos + 1] >> 5) + words[pos + 1] ^ sum
+ key[sum & 3];
}
}
}
msg.Size = BitConverter.ToUInt16(msg.Buffer, 6) + 2 + 6;
msg.Encrypted = false;
}
示例8: ParseClientMessage
public void ParseClientMessage(InMessage message)
{
var packetStart = 0;
try
{
packetStart = message.ReadPosition;
byte cmd = message.ReadByte();
switch (cmd)
{
case 0x96:
ParseClientSay(message);
break;
case 0xF4://244
ParseClientMarketLeave(message);
break;
case 0xF5://245
ParseClientMarketBrowse(message);
break;
case 0xF6://246
ParseClientMarketCreate(message);
break;
case 0xF7://247
ParseClientMarketCancel(message);
break;
case 0xF8://248
ParseClientMarketAccept(message);
break;
}
}
catch (Exception ex)
{
Trace.TraceWarning(ex.Message + "\nPacket Bytes: " + message.Buffer.ToHexString(packetStart, message.ReadPosition - packetStart));
}
}
示例9: ParseInitialize
private void ParseInitialize(InMessage message)
{
int count = message.ReadUShort();
for (int i = 0; i < count; i++)
{
var creature = new Creature(message.ReadUInt());
creature.Type = (CreatureType)message.ReadByte();
creature.Name = message.ReadString();
//Trace.WriteLine(String.Format("Creature[{0}]: {1}", i, creature.Name));
creature.Health = message.ReadByte();
var direction = (Direction)message.ReadByte();
creature.LookDirection = direction;
creature.TurnDirection = direction;
//Outfit
creature.Outfit = message.ReadOutfit();
creature.LightLevel = message.ReadByte();
creature.LightColor = message.ReadByte();
creature.Speed = message.ReadUShort();
creature.Skull = message.ReadByte();
creature.Shield = message.ReadByte();
creature.Emblem = message.ReadByte();
creature.IsImpassable = message.ReadByte() == 0x01;
client.BattleList.AddCreature(creature);
}
ParseTibiaPackets(message);
}
示例10: ParseServerMoveWest
private void ParseServerMoveWest(InMessage message)
{
var location = new Location(client.PlayerLocation.X - 1, client.PlayerLocation.Y, client.PlayerLocation.Z);
client.PlayerLocation = location;
var tiles = new List<Tile>();
ParseServerMapDescription(message, tiles, location.X - 8, location.Y - 6, location.Z, 1, 14);
client.Map.OnMapUpdated(tiles);
}
示例11: ParseServerOpenChannel
private void ParseServerOpenChannel(InMessage message)
{
var channelId = message.ReadUShort();
var name = message.ReadString();
var num = message.ReadUShort();
for (int i = 0; i < num; i++)
message.ReadString();
num = message.ReadUShort();
for (int i = 0; i < num; i++)
message.ReadString();
}
示例12: ParseServerMarketLeave
private void ParseServerMarketLeave(InMessage message)
{
}
示例13: ParseServerMoveSouth
private void ParseServerMoveSouth(InMessage message)
{
var location = new Location(client.PlayerLocation.X, client.PlayerLocation.Y + 1, client.PlayerLocation.Z);
client.PlayerLocation = location;
var tiles = new List<Tile>();
ParseServerMapDescription(message, tiles, location.X - 8, location.Y + 7, location.Z, 18, 1);
client.Map.OnMapUpdated(tiles);
}
示例14: ParseServerHouseTextWindow
private void ParseServerHouseTextWindow(InMessage message)
{
var unk = message.ReadByte();
var windowId = message.ReadUInt();
var text = message.ReadString();
}
示例15: ParseServerMarketEnter
private void ParseServerMarketEnter(InMessage message)
{
message.ReadUInt();
message.ReadByte();
var num = message.ReadUShort();
for (int i = 0; i < num; i++)
message.ReadUInt();
}