public override void _Process(float delta) { try { if (client.HasMessage && !erred) { IServerPacket packet = client.ReceiveMessage(); return; if (packet is motd_spacket motd) { GD.Print("MOTD: " + new string(motd.line.Select(b => (char)b).ToArray())); } else { GD.Print($"Received {packet.GetType().ToString()}"); } } } catch (Exception e) { erred = true; throw e; } }
public static void SendPacket(this AsyncConnection con, IServerPacket pkt) { byte opcode = OpcodeManager.Instance.GetOpcode(pkt.GetType().Name); uint packetid = OpcodeManager.Instance.GetPacketID(pkt.GetType().Name); if (packetid == 0) { TORLog.Error("ERROR: No PacketID defined for " + pkt.GetType().Name); return; } ByteBuffer packet = new ByteBuffer(ByteOrder.LittleEndian); packet.WriteByte(opcode); packet.WriteInt(0); // Length packet.WriteByte(0); // ChkByte packet.WriteUInt(packetid); pkt.WritePacket(con, packet); con.SendTORPacket(packet); TORLog.Network("PktSend @ " + con.GetHashCode() + " >> " + pkt.GetType().Name); }
public static void SendPacket(this AsyncConnection con, IServerPacket pkt) { byte opcode = OpcodeManager.Instance.GetOpcode(pkt.GetType().Name); uint packetid = OpcodeManager.Instance.GetPacketID(pkt.GetType().Name); if (packetid == 0) { TORLog.Error("ERROR: No PacketID defined for " + pkt.GetType().Name); return; } ByteBuffer packet = new ByteBuffer(ByteOrder.LittleEndian); packet.WriteByte(opcode); packet.WriteInt(0); // Length packet.WriteByte(0); // ChkByte packet.WriteUInt(packetid); pkt.WritePacket(con, packet); con.SendTORPacket(packet); TORLog.Network("PktSend @ " + con.GetHashCode() + " >> " + pkt.GetType().Name); }