private void Send() { ClientPacket msg = null; var message = TextMessage.Text.Trim(); var target = TextPlayer.Text.Trim(); var count = 0; var connection = GlobalHandler.ConnectionHandler.GetValidConnection(); switch (header) { case ClientHeader.CSayMsg: msg = new CpSayMessage(message, overflow); break; case ClientHeader.CEmoteMsg: msg = new CpEmoteMessage(message, overflow); break; case ClientHeader.CPlayerMsg: msg = new CpPlayerMessage(message, target, overflow); break; case ClientHeader.CBroadcastMsg: msg = new CpBroadcastMessage(message, overflow); break; } while (running) { if (allConnections) { count += msg.SendToAll(); } else { if (connection != null) { msg.Send(connection); ++count; } } UpdateSendLog(msg.Size, count); Thread.Sleep(interval); } }
private void ButtonSend_Click(object sender, EventArgs e) { if (loop) { if (ButtonSend.Text == "Start") { EnableSend(); StartSend(); } else { DisableSend(); StopSend(); } } else { ClientPacket msg = null; var message = TextMessage.Text.Trim(); var target = TextPlayer.Text.Trim(); var count = 0; switch (header) { case ClientHeader.CSayMsg: msg = new CpSayMessage(message, overflow); break; case ClientHeader.CEmoteMsg: msg = new CpEmoteMessage(message, overflow); break; case ClientHeader.CPlayerMsg: msg = new CpPlayerMessage(message, target, overflow); break; case ClientHeader.CBroadcastMsg: msg = new CpBroadcastMessage(message, overflow); break; } if (!allConnections) { var connection = GlobalHandler.ConnectionHandler.GetValidConnection(); if (connection != null) { msg.Send(connection); count = 1; } } else { count = msg.SendToAll(); } UpdateSendLog(msg.Size, count); } }