public static byte[] HubUserlistItem(Leaf x, uint ident, LinkUser user) { TCPPacketWriter packet = new TCPPacketWriter(); packet.WriteUInt32(ident); packet.WriteString(x, user.OrgName); packet.WriteString(x, user.Name); packet.WriteString(x, user.Version); packet.WriteGuid(user.Guid); packet.WriteUInt16(user.FileCount); packet.WriteIP(user.ExternalIP); packet.WriteIP(user.LocalIP); packet.WriteUInt16(user.Port); packet.WriteString(x, user.DNS); packet.WriteByte((byte)(user.Browsable ? 1 : 0)); packet.WriteByte(user.Age); packet.WriteByte(user.Sex); packet.WriteByte(user.Country); packet.WriteString(x, user.Region); packet.WriteByte((byte)user.Level); packet.WriteUInt16(user.Vroom); packet.WriteByte((byte)(user.CustomClient ? 1 : 0)); packet.WriteByte((byte)(user.Muzzled ? 1 : 0)); packet.WriteByte((byte)(user.WebClient ? 1 : 0)); packet.WriteByte((byte)(user.Encrypted ? 1 : 0)); packet.WriteByte((byte)(user.Registered ? 1 : 0)); packet.WriteByte((byte)(user.Idle ? 1 : 0)); byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_USERLIST_ITEM); packet = new TCPPacketWriter(); packet.WriteBytes(buf); return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO)); }
private static void LeafAdmin(Leaf leaf, TCPPacketReader packet) { if (leaf.LoginPhase != LinkLogin.Ready) { leaf.SendPacket(HubOutbound.LinkError(LinkError.BadProtocol)); leaf.Disconnect(); return; } uint target_ident = packet; Leaf l = LeafPool.Leaves.Find(x => x.Ident == target_ident && x.LoginPhase == LinkLogin.Ready); if (l != null) { String sender_name = packet.ReadString(leaf); LinkUser admin = leaf.Users.Find(x => x.Name == sender_name); String target_name = packet.ReadString(leaf); LinkUser target = l.Users.Find(x => x.Name == target_name); if (admin != null && target_name != null) { String command = packet.ReadString(leaf); String args = packet.ReadString(leaf); l.SendPacket(HubOutbound.HubAdmin(l, admin, command, target, args)); } } }
public static byte[] HubPart(Leaf x, uint ident, LinkUser user) { TCPPacketWriter packet = new TCPPacketWriter(); packet.WriteUInt32(ident); packet.WriteString(x, user.Name); byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_PART); packet = new TCPPacketWriter(); packet.WriteBytes(buf); return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO)); }
public static byte[] HubPersonalMessage(Leaf x, uint ident, LinkUser user) { TCPPacketWriter packet = new TCPPacketWriter(); packet.WriteUInt32(ident); packet.WriteString(x, user.Name); packet.WriteString(x, user.PersonalMessage, false); byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_PERSONAL_MESSAGE); packet = new TCPPacketWriter(); packet.WriteBytes(buf); return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO)); }
public static byte[] HubVroomChanged(Leaf x, uint ident, LinkUser user) { TCPPacketWriter packet = new TCPPacketWriter(); packet.WriteUInt32(ident); packet.WriteString(x, user.Name); packet.WriteUInt16(user.Vroom); byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_VROOM_CHANGED); packet = new TCPPacketWriter(); packet.WriteBytes(buf); return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO)); }
public static byte[] HubAdmin(Leaf x, LinkUser admin, String command, LinkUser target, String args) { TCPPacketWriter packet = new TCPPacketWriter(); packet.WriteUInt32(admin.Ident); packet.WriteString(x, admin.Name); packet.WriteString(x, target.Name); packet.WriteString(x, command); packet.WriteString(x, args); byte[] buf = packet.ToLinkPacket(LinkHub.LinkMsg.MSG_LINK_HUB_ADMIN); packet = new TCPPacketWriter(); packet.WriteBytes(buf); return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO)); }
public static byte[] HubUserUpdated(Leaf x, uint ident, LinkUser user) { TCPPacketWriter packet = new TCPPacketWriter(); packet.WriteUInt32(ident); packet.WriteString(x, user.Name); packet.WriteByte((byte)user.Level); packet.WriteByte((byte)(user.Muzzled ? 1 : 0)); packet.WriteByte((byte)(user.Registered ? 1 : 0)); packet.WriteByte((byte)(user.Idle ? 1 : 0)); byte[] buf = packet.ToLinkPacket(LinkHub.LinkMsg.MSG_LINK_HUB_USER_UPDATED); packet = new TCPPacketWriter(); packet.WriteBytes(buf); return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO)); }
private static void LeafPart(Leaf leaf, TCPPacketReader packet) { if (leaf.LoginPhase != LinkLogin.Ready) { leaf.SendPacket(HubOutbound.LinkError(LinkError.BadProtocol)); leaf.Disconnect(); return; } String name = packet.ReadString(leaf); LinkUser user = leaf.Users.Find(x => x.Name == name); if (user != null) { LeafPool.Leaves.ForEachWhere(x => x.SendPacket(HubOutbound.HubPart(x, leaf.Ident, user)), x => x.Ident != leaf.Ident && x.LoginPhase == LinkLogin.Ready); leaf.Users.RemoveAll(x => x.Name == name); } }
private static void LeafJoin(Leaf leaf, TCPPacketReader packet) { if (leaf.LoginPhase != LinkLogin.Ready) { leaf.SendPacket(HubOutbound.LinkError(LinkError.BadProtocol)); leaf.Disconnect(); return; } LinkUser user = new LinkUser(leaf.Ident); user.OrgName = packet.ReadString(leaf); user.Name = packet.ReadString(leaf); user.Version = packet.ReadString(leaf); user.Guid = packet; user.FileCount = packet; user.ExternalIP = packet; user.LocalIP = packet; user.Port = packet; user.DNS = packet.ReadString(leaf); user.Browsable = ((byte)packet) == 1; user.Age = packet; user.Sex = packet; user.Country = packet; user.Region = packet.ReadString(leaf); user.Level = (iconnect.ILevel)((byte)packet); user.Vroom = packet; user.CustomClient = ((byte)packet) == 1; user.Muzzled = ((byte)packet) == 1; user.WebClient = ((byte)packet) == 1; user.Encrypted = ((byte)packet) == 1; user.Registered = ((byte)packet) == 1; user.Idle = ((byte)packet) == 1; user.PersonalMessage = String.Empty; user.CustomName = String.Empty; user.Avatar = new byte[] { }; leaf.Users.Add(user); LeafPool.Leaves.ForEachWhere(x => x.SendPacket(HubOutbound.HubUserlistItem(x, leaf.Ident, user)), x => x.Ident != leaf.Ident && x.LoginPhase == LinkLogin.Ready); }
private static void LeafUserUpdated(Leaf leaf, TCPPacketReader packet) { if (leaf.LoginPhase != LinkLogin.Ready) { leaf.SendPacket(HubOutbound.LinkError(LinkError.BadProtocol)); leaf.Disconnect(); return; } String name = packet.ReadString(leaf); LinkUser user = leaf.Users.Find(x => x.Name == name); if (user != null) { user.Level = (iconnect.ILevel)((byte)packet); user.Muzzled = ((byte)packet) == 1; user.Registered = ((byte)packet) == 1; user.Idle = ((byte)packet) == 1; LeafPool.Leaves.ForEachWhere(x => x.SendPacket(HubOutbound.HubUserUpdated(x, leaf.Ident, user)), x => x.Ident != leaf.Ident && x.LoginPhase == LinkLogin.Ready); } }