private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { if (wa.ConnectionStatus == ApiBase.CONNECTION_STATUS.LOGGEDIN) { if (!wa.HasMessages()) { wa.PollMessages(); } } }
private void ProcessMessages(object sender, DoWorkEventArgs args) { if (sender == null) { return; } while (this.isRunning) { if (!client.HasMessages()) { client.pollMessage(true); Thread.Sleep(100); continue; } } }
private void ProcessMessages(object sender, DoWorkEventArgs args) { if (sender == null) { return; } while (this.isRunning) { if (!wa.HasMessages()) { wa.PollMessages(); Thread.Sleep(100); continue; } var tmpMessages = wa.GetAllMessages(); (sender as BackgroundWorker).ReportProgress(1, tmpMessages); } }
private static void ProcessChat(WhatsApp wa, string dst) { var thRecv = new Thread(t => { try { while (wa != null) { if (!wa.HasMessages()) { wa.PollMessages(); Thread.Sleep(100); continue; } var buff = wa.GetAllMessages(); } } catch (ThreadAbortException) { } }) { IsBackground = true }; thRecv.Start(); WhatsUserManager usrMan = new WhatsUserManager(); var tmpUser = usrMan.CreateUser(dst, "User"); while (true) { string line = Console.ReadLine(); if (line == null && line.Length == 0) { continue; } string command = line.Trim(); switch (command) { case "/query": //var dst = dst//trim(strstr($line, ' ', FALSE)); PrintToConsole("[] Interactive conversation with {0}:", tmpUser); break; case "/accountinfo": PrintToConsole("[] Account Info: {0}", wa.GetAccountInfo().ToString()); break; case "/lastseen": PrintToConsole("[] Request last seen {0}", tmpUser); wa.RequestLastSeen(tmpUser.GetFullJid()); break; case "/exit": wa = null; thRecv.Abort(); return; case "/start": wa.WhatsSendHandler.SendComposing(tmpUser.GetFullJid()); break; case "/pause": wa.WhatsSendHandler.SendPaused(tmpUser.GetFullJid()); break; case "/register": { RegisterAccount(); break; } default: PrintToConsole("[] Send message to {0}: {1}", tmpUser, line); wa.Message(tmpUser.GetFullJid(), line); break; } } }