Exemplo n.º 1
0
 public SharedMemoryChannel(string name, IMessageDispatcher dispatcher)
 {
     //注意队列名称相反
     _sendQueue     = new SharedMessageQueue($"{name}-R");
     _receiveQueue  = new SharedMessageQueue($"{name}-S");
     _pendingMsgs   = new Dictionary <int, IntPtr>();
     _msgDispatcher = dispatcher;
 }
Exemplo n.º 2
0
        public SharedMemoryChannel(string name, int count, IMessageDispatcher dispatcher, ulong remoteRuntimeId)
        {
            //TODO:判断Host进程

            _sendQueue      = new SharedMessageQueue($"{name}-S", count);
            _receiveQueue   = new SharedMessageQueue($"{name}-R", count);
            _pendingMsgs    = new Dictionary <int, IntPtr>();
            _msgDispatcher  = dispatcher;
            RemoteRuntimeId = remoteRuntimeId;
        }
Exemplo n.º 3
0
 public unsafe void FinishWrite()
 {
     //设置当前消息包的长度
     _curChunk->DataLength = (ushort)(MessageChunk.PayloadDataSize - (_maxDataPtr - _curDataPtr));
     //将当前消息包标为完整消息结束
     _curChunk->Flag |= (byte)MessageFlag.LastChunk;
     //如果在消息队列内直接发送
     if (_queue != null)
     {
         _queue.PostMessageChunk(_curChunk);
         _queue = null; //注意重置
     }
 }
Exemplo n.º 4
0
        public unsafe void Reset(MessageType msgType, int msgID, ulong sourceId, MessageFlag msgFlag, SharedMessageQueue queue = null)
        {
            _curChunk = null; //必须设置,否则缓存重用有问题

            _msgType  = msgType;
            _msgID    = msgID;
            _sourceId = sourceId;
            _msgFlag  = msgFlag;
            _queue    = queue;

            CreateChunk();

            //第一包设MessageSource
            //_curChunk->MessageSource = srcType;
        }