public void Parse(ConnectionDataEventArgs e) { //Console.WriteLine(e.Data.Dump()); _incomingBuffer.AppendData(e.Data.ToArray()); while (_incomingBuffer.IsPacketAvailable()) { int end = _incomingBuffer.Position; end += _incomingBuffer.ReadInt(32) * 8; while ((end - _incomingBuffer.Position) >= 9) { var message = _incomingBuffer.ParseMessage(); if (message == null) { continue; } try { Logger.LogIncomingPacket(message); // change ConsoleTarget's level to Level.Dump in program.cs if u want to see messages on console. if (message.Consumer != Consumers.None) { if (message.Consumer == Consumers.ClientManager) { ClientManager.Instance.Consume(this, message); // Client should be greeted by ClientManager and sent initial game-setup messages. } else { this.Game.Route(this, message); } } else if (message is ISelfHandler) { (message as ISelfHandler).Handle(this); // if message is able to handle itself, let it do so. } else { Logger.Warn("{0} - ID:{1} has no consumer or self-handler.", message.GetType(), message.Id); } } catch (NotImplementedException) { Logger.Warn("Unhandled game message: 0x{0:X4} {1}", message.Id, message.GetType().Name); } } _incomingBuffer.Position = end; } _incomingBuffer.ConsumeData(); }
public void Parse(ConnectionDataEventArgs e) { //Console.WriteLine(e.Data.Dump()); _incomingBuffer.AppendData(e.Data.ToArray()); while (_incomingBuffer.IsPacketAvailable()) { int end = _incomingBuffer.Position; end += _incomingBuffer.ReadInt(32) * 8; while ((end - _incomingBuffer.Position) >= 9) { try { GameMessage message = _incomingBuffer.ParseMessage(); if (message == null) { continue; } if (message.Consumer != Consumers.None) { this.Universe.Route(this, message); } else if (message is ISelfHandler) { (message as ISelfHandler).Handle(this); // if message is able to handle itself, let it do so. } else { Logger.Warn("Got an incoming message that has no consumer or self-handler " + message.GetType()); } //Logger.LogIncoming(msg); } catch (NotImplementedException) { //Logger.Debug("Unhandled game message: 0x{0:X4} {1}", msg.Id, msg.GetType().Name); } } _incomingBuffer.Position = end; } _incomingBuffer.ConsumeData(); FlushOutgoingBuffer(); }
private static void HandleOutgoingPacket(Packet packet) { OutgoingBuffer.AppendData(packet.Ethernet.IpV4.Tcp.Payload.ToArray <byte>()); while (OutgoingBuffer.IsPacketAvailable()) { int end = OutgoingBuffer.Position; end += OutgoingBuffer.ReadInt(32) * 8; while ((end - OutgoingBuffer.Position) >= 9) { var msg = OutgoingBuffer.ParseMessage(); if (msg == null) { continue; } Logger.LogOutgoingPacket(msg); } OutgoingBuffer.Position = end; } OutgoingBuffer.ConsumeData(); }
public void Parse(ConnectionDataEventArgs e) { //Console.WriteLine(e.Data.Dump()); _incomingBuffer.AppendData(e.Data.ToArray()); while (_incomingBuffer.IsPacketAvailable()) { int end = _incomingBuffer.Position; end += _incomingBuffer.ReadInt(32) * 8; while ((end - _incomingBuffer.Position) >= 9) { var message = _incomingBuffer.ParseMessage(); if (message == null) { continue; } try { Logger.LogIncomingPacket(message); // change ConsoleTarget's level to Level.Dump in program.cs if u want to see messages on console. if (message.Consumer != Consumers.None) { if (message.Consumer == Consumers.ClientManager) { ClientManager.Instance.Consume(this, message); // Client should be greeted by ClientManager and sent initial game-setup messages. } else { this.Game.Route(this, message); } } else if (message is ISelfHandler) { (message as ISelfHandler).Handle(this); // if message is able to handle itself, let it do so. } // Кустарный перехват портала else if (message.Id == 87) { MooNetClient mooNetClient = BnetClient; Logger.Warn("Portal to New Tristram. Version 2.0.", message.GetType(), message.Id); Vector3D ToPortal = new Vector3D(2988.73f, 2798.009f, 24.66344f); try { //Search Old Portals var OldOTG = Player.World.GetActorsBySNO(5648); foreach (var OldP in OldOTG) { OldP.Destroy(); } }catch { } var ToHome = new Portal(Player.World, 5648, Player.World.Game.GetWorld(71150).StartingPoints[0].Tags); ToHome.NameSNOId = 71150; ToHome.Scale = 0.9f; Vector3D PositionToPortal = new Vector3D(Player.Position.X, Player.Position.Y + 3, Player.Position.Z); ToHome.EnterWorld(PositionToPortal); /* * //Первая версия телепорта * if (mooNetClient.InGameClient.Game.GetWorld(71150) != mooNetClient.InGameClient.Player.World) * mooNetClient.InGameClient.Player.ChangeWorld(mooNetClient.InGameClient.Game.GetWorld(71150), ToPortal); * else * mooNetClient.InGameClient.Player.Teleport(ToPortal); */ } else { Logger.Warn("{0} - ID:{1} has no consumer or self-handler.", message.GetType(), message.Id); } } catch (NotImplementedException) { Logger.Warn("Unhandled game message: 0x{0:X4} {1}", message.Id, message.GetType().Name); } } _incomingBuffer.Position = end; } _incomingBuffer.ConsumeData(); }