예제 #1
0
        public static void HandleLeaveSession(Packet packet)
        {
            CmdLeaveSession cmd = new CmdLeaveSession(packet);

            if (packet.Sender.Character.Status.GetState() == typeof(WaitingRoom))
            {
                WaitingRoom room = packet.Sender.Character.Status.GetObject <WaitingRoom>();
                room.Leave(packet.Sender);
                var ack3 = new LeaveSessionAck()
                {
                    Token = packet.Sender.GetIdentifier()
                };
                packet.SendBack(ack3.CreatePacket());


                var ack1 = new ClientPlayerLeftSessionAck()
                {
                    Token = packet.Sender.GetIdentifier()
                };
                room.Broadcast(ack1.CreatePacket());

                var ack2 = new TeacherPlayerLeftSessionAck()
                {
                    StudentName = packet.Sender.Character.Name
                };
                room.Owner.Send(ack2.CreatePacket());
                return;
            }
            else
            {
                packet.SendBackError(21);
                return;
            }
        }