Example #1
0
 public void Broadcast(StreamBuffer packet, User except = null)
 {
     foreach (User user in Users)
     {
         if (user != except)
             user.SendPacket(packet.Clone());
     }
 }
Example #2
0
        public User GetUser(Int32 userNo)
        {
            User user = FindUser(userNo);
            if (user != null)
                return user;

            user = FindUser(userNo);
            if (user == null)
            {
                user = new User(userNo);
                _users.Add(userNo, user);
            }

            return user;
        }
Example #3
0
        public void Enter(User user)
        {
            if (Channels.Contains(this) == false)
                throw new AegisException(ResultCode.IMC_InvalidChannelNo);

            if (Users.Contains(user) == true)
                throw new AegisException(ResultCode.IMC_ExistsUser);

            Users.Add(user);
        }
Example #4
0
 public void Leave(User user)
 {
     Users.Remove(user);
     RemoveChannel(this);
 }
Example #5
0
 public UserProfile(User user)
 {
     _user = user;
 }
Example #6
0
 public TextBox(User user)
 {
     _user = user;
 }
Example #7
0
 public LoginCounter(User user)
 {
     _user = user;
 }
Example #8
0
 private void RemoveUser(User user)
 {
     user.Logout();
        _users.Remove(user.UserNo);
 }
Example #9
0
        private void OnReceived(Session session, StreamBuffer buffer)
        {
            SecurePacketRequest reqPacket = new SecurePacketRequest(buffer);
            reqPacket.Decrypt(_aesIV, _aesKey);
            reqPacket.SkipHeader();

            try
            {
                //  Authentication Packets
                if ((reqPacket.PacketId >> 8) == 0x20)
                {
                    reqPacket.Dispatch(this, "On" + Protocol.GetName(reqPacket.PacketId));
                }

                //  Contents Packets
                else
                {
                    _user = UserManager.Instance.FindUser(reqPacket.UserNo);
                    if (_user == null)
                    {
                        ForceClose("Invalid UserNo.");
                        return;
                    }
                    if (_user.LastSeqNo + 1 != reqPacket.SeqNo)
                    {
                        ForceClose("Invalid Sequence Number.");
                        return;
                    }

                    _user.LastSeqNo = reqPacket.SeqNo;
                    _user.Session = this;
                    _user.LastPulse.Restart();

                    reqPacket.Dispatch(this, "On" + Protocol.GetName(reqPacket.PacketId));
                }
            }
            catch (AegisException e) when (e.ResultCodeNo == AegisResult.BufferUnderflow)
            {
                Logger.Write(LogType.Err, 2, "Packet buffer underflow(PID=0x{0:X}).", reqPacket.PacketId);
            }
        }
Example #10
0
 private void OnClosed(Session session)
 {
     _user?.Logout();
     _user = null;
 }