上一篇我们初步设计了MQTT服务端
这里我们设计客户端MQTT Client,接上一篇
新建Windows窗体FormMqttClient
窗体FormMqttClient设计如图:
窗体FormMqttClient设计器相关代码如下
文件FormMqttClient.Designer.cs
namespace CultureDemo
{
partial class FormMqttClient
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.rtxtMessage = new System.Windows.Forms.RichTextBox();
this.label8 = new System.Windows.Forms.Label();
this.btnPublish = new System.Windows.Forms.Button();
this.btnSubscribe = new System.Windows.Forms.Button();
this.txtContent = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.txtTopicPublish = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.txtTopic = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.btnDisconnect = new System.Windows.Forms.Button();
this.btnConnect = new System.Windows.Forms.Button();
this.txtClientId = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.txtUpwd = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.txtUserName = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.txtPort = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.txtIP = new System.Windows.Forms.TextBox();
this.lb = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// rtxtMessage
//
this.rtxtMessage.Location = new System.Drawing.Point(239, 37);
this.rtxtMessage.Name = "rtxtMessage";
this.rtxtMessage.Size = new System.Drawing.Size(623, 411);
this.rtxtMessage.TabIndex = 51;
this.rtxtMessage.Text = "";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(242, 18);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(29, 12);
this.label8.TabIndex = 50;
this.label8.Text = "消息";
//
// btnPublish
//
this.btnPublish.Location = new System.Drawing.Point(117, 425);
this.btnPublish.Name = "btnPublish";
this.btnPublish.Size = new System.Drawing.Size(75, 23);
this.btnPublish.TabIndex = 49;
this.btnPublish.Text = "发布";
this.btnPublish.UseVisualStyleBackColor = true;
this.btnPublish.Click += new System.EventHandler(this.btnPublish_Click);
//