Example #1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            RawNotification.ServerClient.SharedModels.NetworkPackets.FromServer.AddNotificationFSPacketData result = null;
            while (true)
            {
                try
                {
                    result = await RawNotificationInterface.AddNotificationAsync(new NotificationDataPacket(txt_line1.Text, txt_Line2.Text), new List <IReceiver> {
                        new TestReceiver("d")
                    });

                    break;
                }
                catch // lỗi khi gửi
                {
                    if (MessageBox.Show("Lỗi xảy ra khi gửi yêu cầu tới server\nThử lại?", "Lỗi khi gửi yêu cầu", MessageBoxButtons.RetryCancel) == DialogResult.Cancel)
                    {
                        return;
                    }
                }
            }

            if (result == null) // lỗi khi nhận gói tin trả về
            {
                MessageBox.Show("Đã gửi yêu cầu thành công, nhưng gặp lỗi khi nhận gói tin trả về", "Lỗi khi nhận hồi đáp", MessageBoxButtons.OK);
                return;
            }
            else
            {
                if (result.IsSuccess)
                {
                    MessageBox.Show("Thêm thông báo thành công");
                }
                else
                {
                    MessageBox.Show("thêm thông báo thất bại" + Environment.NewLine + result.ErrorType + Environment.NewLine + result.InnerException);
                }
            }
        }