private void SendMessage() { SingleClientSend self = this; try { while (true) { lock (send_locker) { if (send_locker.Status == 0) { return; } this.batch_count = (this.send_qps < 10) ? this.send_qps : this.batch_count; for (int i = 0; i < this.batch_count; i++) { this._client.SendMessage(778899, (byte)8, "hello !", "", 0, 20 * 1000, (cbd) => { if (cbd.GetException() != null) { self.RevcInc(true); // Debug.Log(cbd.GetException()); } else { self.RevcInc(false); } }); this.SendInc(); } } if (this.send_qps > 0) { Thread.Sleep((int)Math.Ceiling((1000f / this.send_qps) * this.batch_count)); } else { Thread.Sleep(1000); } } } catch (Exception ex) { Debug.Log(ex); } }
public void StartTest(byte[] fileBytes) { this._client = new RTMClient( "52.83.245.22:13325", 11000001, 777779, "FA77FB4FA1E19E3EA7A9500DC6D9649C", RTMConfig.TRANS_LANGUAGE.en, new Dictionary <string, string>(), true, 20 * 1000, // false true ); SingleClientSend self = this; this._client.GetEvent().AddListener("login", (evd) => { if (evd.GetException() == null) { Debug.Log("test start!"); self.StartThread(); } else { Debug.Log(evd.GetException()); } }); this._client.GetEvent().AddListener("close", (evd) => { Debug.Log("closed!"); self.StopThread(); }); this._client.GetEvent().AddListener("error", (evd) => { Debug.Log(evd.GetException()); }); RTMProcessor processor = this._client.GetProcessor(); processor.AddPushService(RTMConfig.SERVER_PUSH.recvMessage, (data) => { Debug.Log("[recvMessage]: " + Json.SerializeToString(data)); }); this._client.Login(null); }