private static void LeafPersonalMessage(Leaf leaf, TCPPacketReader packet) { if (leaf.LoginPhase == LinkLogin.AwaitingLogin) { 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.PersonalMessage = packet.ReadString(leaf); if (leaf.LoginPhase == LinkLogin.Ready) { LeafPool.Leaves.ForEachWhere(x => x.SendPacket(HubOutbound.HubPersonalMessage(x, leaf.Ident, user)), x => x.Ident != leaf.Ident && x.LoginPhase == LinkLogin.Ready); } } }
private static void LeafUserlistEnd(Leaf leaf) { if (leaf.LoginPhase != LinkLogin.AwaitingUserlist) { leaf.SendPacket(HubOutbound.LinkError(LinkError.BadProtocol)); leaf.Disconnect(); return; } leaf.LoginPhase = LinkLogin.Ready; LeafPool.Leaves.ForEachWhere(x => x.SendPacket(HubOutbound.HubLeafConnected(x, leaf)), x => x.Ident != leaf.Ident && x.LoginPhase == LinkLogin.Ready); foreach (LinkUser u in leaf.Users) { LeafPool.Leaves.ForEachWhere(x => x.SendPacket(HubOutbound.HubUserlistItem(x, leaf.Ident, u)), x => x.Ident != leaf.Ident && x.LoginPhase == LinkLogin.Ready); if (u.CustomName.Length > 0) { LeafPool.Leaves.ForEachWhere(x => x.SendPacket(HubOutbound.HubCustomName(x, leaf.Ident, u)), x => x.Ident != leaf.Ident && x.LoginPhase == LinkLogin.Ready); } if (u.Avatar.Length > 0) { LeafPool.Leaves.ForEachWhere(x => x.SendPacket(HubOutbound.HubAvatar(x, leaf.Ident, u)), x => x.Ident != leaf.Ident && x.LoginPhase == LinkLogin.Ready); } if (u.PersonalMessage.Length > 0) { LeafPool.Leaves.ForEachWhere(x => x.SendPacket(HubOutbound.HubPersonalMessage(x, leaf.Ident, u)), x => x.Ident != leaf.Ident && x.LoginPhase == LinkLogin.Ready); } } LeafPool.Leaves.ForEachWhere(x => { leaf.SendPacket(HubOutbound.HubLeafConnected(leaf, x)); foreach (LinkUser u in x.Users) { leaf.SendPacket(HubOutbound.HubUserlistItem(leaf, x.Ident, u)); if (u.CustomName.Length > 0) { leaf.SendPacket(HubOutbound.HubCustomName(leaf, x.Ident, u)); } if (u.Avatar.Length > 0) { leaf.SendPacket(HubOutbound.HubAvatar(leaf, x.Ident, u)); } if (u.PersonalMessage.Length > 0) { leaf.SendPacket(HubOutbound.HubPersonalMessage(leaf, x.Ident, u)); } } }, x => x.Ident != leaf.Ident && x.LoginPhase == LinkLogin.Ready); }