Beispiel #1
0
        protected override void OnDoWork(DoWorkEventArgs e)
        {
            base.OnDoWork(e);
            writeThreshold = 0;
            otMessage = (Message)e.Argument;
            _RawLog = new List<string>();
            setupLog();
            Connection(otMessage.server);
            

        }
Beispiel #2
0
        private int setChannel(Message mm)
        {

            int nloc = mm.message.IndexOf("#");
            if (nloc < 0)
                return -1;
            int end = mm.message.IndexOf(" ", nloc);
            if (end < 1)
                return -1;
            if (nloc >= end)
                return -1;
            selectedchannel = mm.message.Substring(nloc + 1, end - nloc);
            return nloc;
        }
Beispiel #3
0
        private void process(Message mm)
        {
            string[] ml;
            int cnt;
            if (mm.message.IndexOf(dc.GetNick()) >= 0)
            {
                ml = mm.message.Split(' ');

                if (ml[4].ToLower() == "req")
                {
                    if (ml.Length == 6)
                        DoReq(ml[5], 1);
                    else{
                        if(Int32.TryParse(ml[6],out cnt))
                            DoReq(ml[5],cnt);
                        }
                    }
            }
        }
Beispiel #4
0
        private void Receive()
        {
            string messagefragment = "";
           
            while ( m_socket.Connected)
            {
                try
                {
                    
                    Byte[] buffer = new byte[512];
                    string received;
                    int index = 0;
                    bool NeedParsing = true;
                    if (m_socket.Receive(buffer) > 0)
                    {
                        oMessList = new List<Message>();
                        Message oM;
                        
                        received = Encoding.Default.GetString(buffer);
                        string[] MessageQueue = received.Split("\r\n".ToCharArray());
                        index = 0;
                        foreach (string message in MessageQueue)
                        {

                           
                            index++;
                            oM = new Message();
                            
                            NeedParsing = true;
                            oM.Direction = "";
                            oM.Status = "started";
                            oM.message = message;
                            _RawLog.Add(message + "\n");
                            writer.WriteLine(message);
                            writeThreshold++;
                            if (writeThreshold % 10 == 0)
                                writer.Flush();
                            oM.Index = index - 1;
                            if (MessageQueue.Length == index)
                                oM.Status = "done";
                            oMessList.Add(oM);
                            if (message.StartsWith(":") == false && message.StartsWith("PING") == false && message.StartsWith("NOTICE") == false && index == 1)
                            {
                                string tempmessage = messagefragment + message;
                                NeedParsing = false;
                                oM.Direction = "parse";
                                ReportProgress(0, oMessList);
                                //OnRawMessageReceived(tempmessage);
                               // m_parser.MainParser(tempmessage.Split(new char[] { ' ' }));
                            }
                            if (index == MessageQueue.Length)
                            {
                                messagefragment = message;
                                NeedParsing = false;
                            }
                            if (message.StartsWith("PING"))
                            {
                                string[] pong = received.Split(new char[] { ':' });
                                SendRaw("PONG " + pong[1]);
                            }
                            else
                            {
                                if (NeedParsing)
                                {
                                    oM.Direction = "parse";
                                    otMessage.message = message;
                                    ReportProgress(0, oMessList);


                                }
                            }
                        }
                        
                    }
                    else
                    {
                        this.ConnectionStatus = ConnectionState.Disconnected;

                        return;
                    }
                }
                catch (Exception ex)
                {
                    this.ConnectionStatus = ConnectionState.Disconnected;
                    otMessage.message = "ERROR: " + ex.Message;
                    //this.OnErrorMessageReceived("ERROR: " + ex.Message);
                    ReportProgress(0,otMessage);
                }
            }
            
        }