Пример #1
0
        public static List <object> Serialize(string recv)
        {
            List <object> requestList = new List <object>();

            string[] rawRequests = recv.Replace("\r", "")
                                   .Split("\n", StringSplitOptions.RemoveEmptyEntries);
            // first we convert request into our ChatCommand class
            // next we handle each command
            foreach (var rawRequest in rawRequests)
            {
                ChatRequestBase generalRequest = new ChatRequestBase(rawRequest);
                if (!generalRequest.Parse())
                {
                    LogWriter.ToLog(LogEventLevel.Error, "Invalid request!");
                    continue;
                }

                Type requestType = AppDomain.CurrentDomain
                                   .GetAssemblies()
                                   .SelectMany(x => x.GetTypes())
                                   .FirstOrDefault(t => t.Name == generalRequest.CmdName + "Request");
                if (requestType != null)
                {
                    var specificRequest = Activator.CreateInstance(requestType, generalRequest.RawRequest);
                    if (specificRequest == null)
                    {
                        LogWriter.ToLog(LogEventLevel.Error, $"Unknown request {generalRequest.CmdName}!");
                        continue;
                    }
                    if (!((ChatRequestBase)specificRequest).Parse())
                    {
                        LogWriter.ToLog(LogEventLevel.Error, "Invalid request!");
                        continue;
                    }
                    requestList.Add(specificRequest);
                }
                else
                {
                    LogWriter.ToLog(LogEventLevel.Error, $"Request: {generalRequest.CmdName} not implemented!");
                }
            }
            return(requestList);
        }
Пример #2
0
 public NICKHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request = (NICKRequest)request;
 }
Пример #3
0
 public WHOHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request = (WHORequest)request;
 }
Пример #4
0
 public SETCKEYHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request            = (SETCKEYRequest)request;
     IsSetOthersKeyValue = false;
 }
Пример #5
0
 public LOGINHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request = (LOGINRequest)request;
 }
Пример #6
0
 public NOTICEHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request = new NOTICERequest(request.RawRequest);
 }
Пример #7
0
 public TOPICHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request = (TOPICRequest)request;
 }
Пример #8
0
 public USRIPHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request = (USRIPRequest)request;
 }
Пример #9
0
 // CRYPT des 1 gamename
 public CRYPTHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request = (CRYPTRequest)request;
 }
 public SETCHANKEYHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request = (SETCHANKEYRequest)request;
 }
Пример #11
0
 public PARTHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request = (PARTRequest)request;
 }
Пример #12
0
 public GETCKEYHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request = (GETCKEYRequest)request;
 }
Пример #13
0
 //:irc.foonet.com 321 Pants Channel :Users  Name\r\n:irc.foonet.com 323 Pants :End of /LIST\r\n
 public LISTHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request = (LISTRequest)request;
 }
Пример #14
0
 public QUITHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request = (QUITRequest)request;
 }
Пример #15
0
 public NAMESHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request = (NAMESRequest)request;
 }
Пример #16
0
 public PRIVMSGHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request = (PRIVMSGRequest)request;
 }
Пример #17
0
 public UTMHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request = (UTMRequest)request;
 }
Пример #18
0
 public MODEHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request = (MODERequest)request;
 }