IFConn.cs 1.19 KB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FObjBase
{
    
    public interface IFConn
    {
        /// <summary>
        /// 连接状态改变
        /// </summary>
        ConnectHandler ConnectAction { get; set; }
        /// <summary>
        /// 协议翻译器
        /// </summary>
        ParsePacketHandler ParsePacket { get; set; }
        /// <summary>
        /// 已经成功连接上
        /// </summary>
        bool IsConnected { get; }
        /// <summary>
        /// 运行中
        /// </summary>
        bool IsRunning { get; }
        /// <summary>
        ///  开始运行
        /// </summary>
        void Start();
        /// <summary>
        /// 结束运行
        /// </summary>
        void Stop();

        /// <summary>
        /// IsRunning = false 事件
        /// </summary>
        event ClosedHandler Closed;


        bool HasCRC { get; set; }
        /// <summary>
        /// 发送数据
        /// </summary>
        /// <param name="buffer"></param>
        void SendPacket(byte[] buffer);


    }
    public delegate void ConnectHandler(IFConn conn);
    public delegate void ClosedHandler(IFConn conn);
}