Exemple #1
0
        private void SegmentParser_DataReceived(object sender, NetDataReceivedEventArgs e)
        {
            MessageSegmentParser parser = (MessageSegmentParser)sender;

            RemoveSegmentParser(parser);
            OnMessageReceived(e);
        }
Exemple #2
0
        private MessageSegmentParser CreateSegmentParser(IPEndPoint remoteEndPoint, MessageSegment segment)
        {
            MessageSegmentParser segmentParser = new MessageSegmentParser(remoteEndPoint, segment.MessageId, segment.TotalLength);

            segmentParser.DataReceived += SegmentParser_DataReceived;
            return(segmentParser);
        }
Exemple #3
0
        private void RemoveSegmentParser(MessageSegmentParser parser)
        {
            parser.DataReceived -= SegmentParser_DataReceived;
            var endPointInfo = new EndPointInfo(parser.RemoteEndPoint);

            if (_parseData.ContainsKey(endPointInfo))
            {
                if (_parseData[endPointInfo].Remove(parser.MessageId))
                {
                    if (_parseData[endPointInfo].Count == 0)
                    {
                        _parseData.Remove(endPointInfo);
                    }
                }
            }
        }