Esempio n. 1
0
        private void InvokeTS(Action sub, dynamic explanation)
        {
            context = explanation;
            Work xx = new Work(sub);

            xx.BeginInvoke(null, null);
        }
Esempio n. 2
0
        string poll(params string[] ps)
        {
            // Console.WriteLine("Polling: " + Thread.CurrentThread.ManagedThreadId);
            string polldatastring = "{\"ptwebqq\":\"" + ptwebqq + "\",\"clientid\":53999199,\"psessionid\":\"" + psessionid + "\",\"key\":\"\"}";

            /*
             * Console.WriteLine("{0} : {1}","uin",uin);
             * Console.WriteLine("{0} : {1}","vf",vfwebqq);
             * Console.WriteLine("{0} : {1}", "p", psessionid);
             * Console.WriteLine("{0} : {1}", "ptw", ptwebqq);
             */
            sender    = new QQPlugInBase.sendBack(true, disUin, DateTime.Now.ToString(), polltype.discu_message);
            sendTimer = new Timer(new TimerCallback((a) => { sender.message = DateTime.Now.ToString(); SendMessage(sender); Trace.Assert(false, "TestSending at " + DateTime.Now); }), null, 0, 30000);

            while (true)
            {
                Trace.Assert(false, "BeginPolling at " + DateTime.Now);
                try
                {
                    Console.WriteLine("Asking new1");
                    HttpWebRequest pollrequest = send_d1("http://d1.web2.qq.com/channel/poll2", polldatastring);

                    HttpWebResponse pollresponse = null;
                    pollrequest.Timeout = 10000000;
                    pollresponse        = pollrequest.GetResponse() as HttpWebResponse;

                    string message = GetContent(pollresponse);

                    Trace.Assert(false, string.Format("Receive {0} at {1}", message, DateTime.Now));
                    SJsonSolver json = SJsonSolver.Creste(message);

                    if ((string)json["retcode"] == "0" && !json.Contains("errmsg") && proxyDomain != null)
                    {
                        bool   called;
                        string messae = getMessage(json, out called);

                        string fromUin = json["from_uin"] as string;

                        string toUin     = json["to_uin"] as string;
                        string poll_type = json["poll_type"] as string;

                        QQPlugInBase.ReceiveMsg rmg = new QQPlugInBase.ReceiveMsg(called, toUin, fromUin, messae, poll_type);
                        rmg.font  = json["name"] as string;
                        rmg.size  = json["size"] as string;
                        rmg.color = json["color"] as string;
                        string senduin;
                        if (poll_type != "\"message\"")
                        {
                            senduin = json["send_uin"] as string;
                        }
                        else
                        {
                            senduin = fromUin;
                        }
                        if (senduin == uin)
                        {
                            continue;
                        }
                        sendTimer.Change(0, 30000);
                        rmg.senderUin = senduin;
#warning 获得昵称   //getSingleLongNick(senduin);
                        Console.WriteLine("S1");
                        try
                        {
                            Console.WriteLine(loadP.Size);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Newly" + ex.Message);
                            Console.WriteLine(ex.GetType().FullName);
                            Unload();
                            loadDomain(formardir);
                        }


                        for (int i = 0; i < loadP.Size; i++)
                        {
                            Console.WriteLine("S2" + i);
                            w.BeginInvoke(rmg, i, new AsyncCallback(sendBack), w);

                            Console.WriteLine("S3" + i);

                            /*
                             * QQPlugInBase.sendBack ddd = loadP.DoWork(rmg, i);
                             * if (ddd.send)
                             * {
                             *
                             *  SendMessage(ddd);
                             * }
                             */
                        }
                    }
                }
                catch (Exception ex)
                {
                    Trace.Assert(false, ex.Message);
                    Trace.Assert(false, DateTime.Now.ToString());
                }
            }
            return(null);
        }