using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dispatch
{
///
/// 接收事务数据
///
public class ReceivedEventArgs : EventArgs
{
///
/// 字节缓存
///
public byte[] buffer;
///
/// 类型
///
public string type;
}
///
/// 虚拟通信基类
///
public abstract class CommunicationBase
{
///
/// 发送数据
///
///
///
public abstract void SendData(byte[] buffer,object o);
///
/// 接收事件操作
///
///
///
public delegate void ReceivedEventHandler(object o, ReceivedEventArgs e);
///
/// 接收事件
///
public event ReceivedEventHandler ReceivedEvent;
///
/// 打开联接
///
public abstract void Open();
///
/// 关闭联接
///
public abstract void Close();
private bool isOpen;
///
/// 通信标识
///
///
public virtual object GetTag()
{
return null;
}
///
/// 联接是否打开
///
public bool IsOpen
{
get { return isOpen; }
set { isOpen = value; }
}
///
/// 接收信息处理
///
///
///
protected virtual void OnReceivedEvent(object o, ReceivedEventArgs e)
{
if (ReceivedEvent != null)
{
ReceivedEvent(o, e);
}
}
///
/// 释放联接
///
public virtual void Dispose()
{
}
}
}