1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Services
- {
- /// <summary>
- /// 接收事件类
- /// </summary>
- public class ReceivedEventArgs:EventArgs
- {
- public byte[] buffer;
- public string type;
- }
- /// <summary>
- /// 通讯基类
- /// </summary>
- public abstract class CommunicationBase:IDisposable
- {
- 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()
- {
-
- }
- }
- }
|