示例#1
0
 internal void RaiseMessage(DhcpSession session, DhcpMessageEventArgs e)
 {
     if (OnMessage != null)
     {
         OnMessage(session, e);
     }
 }
示例#2
0
        /// <summary>收到数据时触发</summary>
        /// <param name="e"></param>
        protected override void OnReceive(ReceivedEventArgs e)
        {
            var dhcp = new DhcpEntity();

            dhcp.Read(e.Stream, null);

            var kind = dhcp.Kind;

            WriteLog("收到:{0} {1}", kind, e.Remote);
            var ds = (this as INetSession).Host as DhcpServer;

            var dme = new DhcpMessageEventArgs
            {
                Request   = dhcp,
                Remote    = e.Remote,
                UserState = e.UserState
            };

            OnMessage?.Invoke(this, dme);

            ds.RaiseMessage(this, dme);

            if (dme.Response != null)
            {
                var buf = dme.Response.ToArray();
                Send(buf);
            }

            base.OnReceive(e);
        }