private void onError(object sender, WebSocketSharp.ErrorEventArgs e) { VebSocketError ve = new VebSocketError(); ve.Exception = e.Exception; ve.Message = e.Message; this.Errors.Add(ve); }
private void onMessageSent(object sender, SentMessageEventArgs e) { var cm = this.SendingMessages[e.GUID]; cm.Frames = 0; cm.Age.Restart(); if (e.Sent) { this.SentMessages.Add(e.GUID, cm); } else { VebSocketError ve = new VebSocketError(); ve.Exception = null; ve.Message = "Message " + e.GUID.ToString() + " is not sent."; } this.SendingMessages.Remove(e.GUID); }
private void ClearBuffers(object sender, EventArgs e) { if (this.AutoFlush) { this.RemovableMessages.Clear(); foreach (KeyValuePair <Guid, ClientMessage> kvp in this.ReceivedMessages) { if (kvp.Value.Frames >= this.MaximumFramesForMessages) { this.RemovableMessages.Add(kvp.Key); } } foreach (Guid g in this.RemovableMessages) { this.ReceivedMessages.Remove(g); } this.RemovableMessages.Clear(); foreach (KeyValuePair <Guid, ClientMessage> kvp in this.SendingMessages) { if (kvp.Value.Age.Elapsed.TotalSeconds > this.SendingMessageTimeout) { this.RemovableMessages.Add(kvp.Key); VebSocketError ve = new VebSocketError(); ve.Exception = null; ve.Message = "Message " + kvp.Key.ToString() + " is expired."; } } foreach (Guid g in this.RemovableMessages) { this.SendingMessages.Remove(g); } this.RemovableMessages.Clear(); foreach (KeyValuePair <Guid, ClientMessage> kvp in this.SentMessages) { if (kvp.Value.Frames >= this.MaximumFramesForMessages) { this.RemovableMessages.Add(kvp.Key); } } foreach (Guid g in this.RemovableMessages) { this.SentMessages.Remove(g); } this.RemovableMessages.Clear(); this.RemovableErrors.Clear(); for (int i = 0; i < this.Errors.Count; i++) { if (this.Errors[i].Age.Elapsed.TotalSeconds > this.MaximumAgeForErrors) { this.RemovableErrors.Add(i); } } foreach (int i in this.RemovableErrors) { this.Errors.RemoveAt(i); } this.RemovableErrors.Clear(); } if (this.AutoFlushLog) { this.RemovableMessages.Clear(); foreach (Stopwatch sw in this.LogMessages.Keys) { if (sw.Elapsed.TotalSeconds > this.MaximumAgeForLog) { this.RemovableLog.Add(sw); } } foreach (Stopwatch sw in this.RemovableLog) { this.LogMessages.Remove(sw); } this.RemovableMessages.Clear(); } }