示例#1
0
 private void button2_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < 10000; i++)
     {
         var message = new CommonService.Message();
         message.Content = "Data:" + i;
         var bytes = this.process.FormatterMessageBytes(message);
         this.client.Send(bytes, bytes.Length);
     }
 }
示例#2
0
        private void button5_Click(object sender, EventArgs e)
        {
            var message = new CommonService.Message();

            message.Data = new byte[int.MaxValue / 3];
            var bytes = this.process.FormatterMessageBytes(message);

            message.Content = "Length:" + FormatFileSize(bytes.Length);
            bytes           = this.process.FormatterMessageBytes(message);
            this.client.Send(bytes, bytes.Length);
        }
示例#3
0
        private void Client_MessageReceived(CommonService.Message message)
        {
            switch (message.Type)
            {
            case MessageType.Text:
            case MessageType.Data:
                this.Log((message as TextMessage).Text);
                break;

            case MessageType.RawData:
            {
                var msg = message as FileInfoMessage;
                recvFileLength = msg.FileSize;
                recvFileMD5    = msg.FileMD5;
                this.SetProgress(0);
                this.Log(string.Format(@"Receiving start:
FileName={0}
FileSize={1}
MD5={2}", msg.FileName, msg.FileSize.ToFileSize(), msg.FileMD5));
                var dir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ReceivedFiles");
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                var filePath = Path.Combine(dir, msg.FileName);
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
                recvFileStream = File.Create(filePath);
            }
            break;

            default:
                throw new Exception("Unexpected message type!");
            }
        }
示例#4
0
 void process_ReceiveMessage(CommonService.Message obj)
 {
     this.textBox1.Invoke(actlog, obj.Content);
 }