123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System;
- using Sers.Core.CL.MessageDelivery;
- using Vit.Core.Module.Log;
- namespace Sers.CL.Ipc.SharedMemory
- {
- public class DeliveryClient : IDeliveryClient
- {
- public DeliveryClient()
- {
- _conn = new DeliveryConnection();
- }
- /// <summary>
- /// 请勿处理耗时操作,需立即返回。接收到客户端的数据事件
- /// </summary>
- public Action<IDeliveryConnection, ArraySegment<byte>> Conn_OnGetFrame { set => _conn.OnGetFrame = value; }
- public Action<IDeliveryConnection> Conn_OnDisconnected { set => _conn.OnDisconnected = value; }
- readonly DeliveryConnection _conn;
- public IDeliveryConnection conn => _conn;
- //-------------------------------------------------------
- /// <summary>
- /// 共享内存名称
- /// </summary>
- public string name { get; set; } = "Sers.CL.Ipc";
- public void Close()
- {
- _conn.Close();
- }
- public bool Connect()
- {
- Logger.Info("[CL.Ipc] Ipc.SharedMemory,connecting", new { name });
- if (!_conn.InitAsClient(name))
- {
- Close();
- return false;
- }
- if (!_conn.Start())
- {
- Close();
- return false;
- }
- Logger.Info("[CL.Ipc] Ipc.SharedMemory,connected");
- return true;
- }
- }
- }
|