NeovimClient/MsgPackIO.cs
/// <summary>
/// Gets executed if BeginRead() has red some data
/// </summary>
/// <param name="ar">Async Result</param>
Gets executed if BeginRead() has red some data
Gets executed if BeginRead () has red some data
private void OutputCallback(IAsyncResult ar)
        {
            AsyncState state = (AsyncState)ar.AsyncState;
            int count = state.Stream.BaseStream.EndRead(ar);
            if (count > 0)
            {
                int readCount = 0;
                while (count > readCount)
                {
                    var data = Unpacking.UnpackObject(state.Buffer, readCount);
                    readCount += data.ReadCount;
                    if (!data.Value.IsArray)
                        Debugger.Break();
                    var dataList = data.Value.AsList().Select(x => new MessagePackObject(x)).ToList();
                    if (dataList.Count == 4)
                    {
                        var type = (MessageType)dataList[0].AsInteger();
                        if (type != MessageType.Response)
                            Debugger.Break();
                        var msgId = dataList[1].AsInteger();
                        var err = dataList[2];
                        var res = dataList[3];
                        _tcs[msgId].SetResult(new[] { err, res });
                    }
                    else if (dataList.Count == 3)
                    {
                        var type = (MessageType)dataList[0].AsInteger();
                        if (type != MessageType.Notification)
                            Debugger.Break();
                        var func = dataList[1].AsString(Encoding.Default);
                        var res = dataList[2];
                        MsgPackNotificationEventArgs args = new MsgPackNotificationEventArgs
                        {
                            Method = func,
                            Params = res
                        };
                        OnNotificationReceived(args);
                    }
                    else Debugger.Break();
                }
                Array.Clear(state.Buffer, 0, state.Buffer.Length);
                _standardOutput.BaseStream.BeginRead(
                    _outputBuffer, 0,
                    _outputBuffer.Length,
                    _outputReady,
                    _outputState
                    );
            }
        }
private void OutputCallback ( IAsyncResult ar ) { AsyncState state = ( AsyncState ) ar . AsyncState ; int count = state . Stream . BaseStream . EndRead ( ar ) ; if ( count > 0 ) { int readCount = 0 ; while ( count > readCount ) { var data = Unpacking . UnpackObject ( state . Buffer , readCount ) ; readCount += data . ReadCount ; if ( ! data . Value . IsArray ) Debugger . Break ( ) ; var dataList = data . Value . AsList ( ) . Select ( x => new MessagePackObject ( x ) ) . ToList ( ) ; if ( dataList . Count == 4 ) { var type = ( MessageType ) dataList [ 0 ] . AsInteger ( ) ; if ( type != MessageType . Response ) Debugger . Break ( ) ; var msgId = dataList [ 1 ] . AsInteger ( ) ; var err = dataList [ 2 ] ; var res = dataList [ 3 ] ; _tcs [ msgId ] . SetResult ( new [ ] { err , res } ) ; } else if ( dataList . Count == 3 ) { var type = ( MessageType ) dataList [ 0 ] . AsInteger ( ) ; if ( type != MessageType . Notification ) Debugger . Break ( ) ; var func = dataList [ 1 ] . AsString ( Encoding . Default ) ; var res = dataList [ 2 ] ; MsgPackNotificationEventArgs args = new MsgPackNotificationEventArgs { Method = func , Params = res } ; OnNotificationReceived ( args ) ; } else Debugger . Break ( ) ; } Array . Clear ( state . Buffer , 0 , state . Buffer . Length ) ; _standardOutput . BaseStream . BeginRead ( _outputBuffer , 0 , _outputBuffer . Length , _outputReady , _outputState ) ; } }
Gets executed if BeginRead() has red some data
Gets executed if BeginRead () has red some data
// Response message has 4 items in the array // Notification message has 3 items in the array
ar
IAsyncResult
None