コード例 #1
0
    private static void HandleInvite(GameSession session, PacketReader packet)
    {
        string targetPlayer = packet.ReadUnicodeString();
        int    groupChatId  = packet.ReadInt();

        GroupChat groupChat = GameServer.GroupChatManager.GetGroupChatById(groupChatId);

        if (groupChat is null)
        {
            return;
        }

        Player other = GameServer.PlayerManager.GetPlayerByName(targetPlayer);

        if (other is null)
        {
            session.Send(GroupChatPacket.Error(session.Player, targetPlayer, (int)GroupChatError.OfflinePlayer));
            return;
        }

        if (other.GroupChats.Count >= 3) // 3 is the max group chats a user can be at
        {
            session.Send(GroupChatPacket.Error(session.Player, targetPlayer, (int)GroupChatError.MaxGroups));

            return;
        }

        session.Send(GroupChatPacket.Invite(session.Player, other, groupChat));
        groupChat.BroadcastPacketGroupChat(GroupChatPacket.UpdateGroupMembers(session.Player, other, groupChat));

        groupChat.AddMember(other);

        other.Session.Send(GroupChatPacket.Update(groupChat));
        other.Session.Send(GroupChatPacket.Join(session.Player, other, groupChat));
    }
コード例 #2
0
    private static void HandleChat(GameSession session, PacketReader packet)
    {
        string message     = packet.ReadUnicodeString();
        int    groupChatId = packet.ReadInt();

        GroupChat groupChat = GameServer.GroupChatManager.GetGroupChatById(groupChatId);

        if (groupChat is null)
        {
            return;
        }

        groupChat.BroadcastPacketGroupChat(GroupChatPacket.Chat(groupChat, session.Player, message));
    }
コード例 #3
0
    private static void HandleLeave(GameSession session, PacketReader packet)
    {
        int groupChatId = packet.ReadInt();

        GroupChat groupChat = GameServer.GroupChatManager.GetGroupChatById(groupChatId);

        if (groupChat is null)
        {
            return;
        }

        groupChat.RemoveMember(session.Player);
        session.Send(GroupChatPacket.Leave(groupChat));
        groupChat.BroadcastPacketGroupChat(GroupChatPacket.LeaveNotice(groupChat, session.Player));
    }