wtt
2024-09-20 d9b200d424889c069953ec084ef9d4dd6c4ff66b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Taobao.Top.Link.Channel
{
    /// <summary>context used with channel event
    /// </summary>
    public class ChannelContext : EventArgs
    {
        /// <summary>error from channel
        /// </summary>
        public Exception Error { get; private set; }
        /// <summary>the channel used to sending message
        /// </summary>
        public IChannelSender Sender { get; private set; }
        /// <summary>received message
        /// </summary>
        public object Message { get; private set; }
 
        public ChannelContext(Exception error)
        {
            this.Error = error;
        }
        public ChannelContext(object message, IChannelSender sender)
        {
            this.Message = message;
            this.Sender = sender;
        }
 
        /// <summary>
        /// send data to channel where the message come from
        /// </summary>
        /// <param name="data"></param>
        public void Reply(byte[] data)
        {
            if (this.Sender == null)
                throw new LinkException("can not send");
            this.Sender.Send(data);
        }
    }
}