示例#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);
        }
 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;
 }
 public LOGINHandler(ISession session, ChatRequestBase request) : base(session, request)
 {
     _request = (LOGINRequest)request;
 }
 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;
 }
 // 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;
 }
 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;
 }
 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;
 }