예제 #1
0
        protected virtual void OnNotificationReceived(MsgPackNotificationEventArgs e)
        {
            MsgPackNotificationEventHandler handler = NotificationReceived;

            if (handler != null)
            {
                handler(this, e);
            }
        }
예제 #2
0
        /// <summary>
        /// Fires a redraw event after getting a notification from the MsgPackIO class
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="msgPackNotificationEventArgs"></param>
        private void OnNotificationReceived(object sender, MsgPackNotificationEventArgs msgPackNotificationEventArgs)
        {
            if (msgPackNotificationEventArgs.Method != "redraw")
            {
                return;
            }

            NeovimRedrawEventArgs args = new NeovimRedrawEventArgs();

            args.Methods = NotificationParser.ParseRedraw(msgPackNotificationEventArgs.Params.AsList());
            OnRedraw(args);
        }
예제 #3
0
        /// <summary>
        /// Gets executed if BeginRead() has red some data
        /// </summary>
        /// <param name="ar">Async Result</param>
        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();

                    // Response message has 4 items in the array
                    if (dataList.Count == 4)
                    {
                        var type = (MessageType)dataList[0].AsInt64();
                        if (type != MessageType.Response)
                            Debugger.Break();

                        var msgId = dataList[1].AsInt32();

                        var err = dataList[2];
                        var res = dataList[3];

                        tcs[msgId].SetResult(new[] { err, res });
                    }

                    // Notification message has 3 items in the array
                    else if (dataList.Count == 3)
                    {
                        var type = (MessageType)dataList[0].AsInt64();
                        if (type != MessageType.Notification)
                            Debugger.Break();

                        var func = dataList[1].AsString(Encoding.Default);

                        var res = dataList[2];

                        MsgPackNotificationEventArgs args = new MsgPackNotificationEventArgs();
                        args.Method = func;
                        args.Params = res;
                        OnNotificationReceived(args);
                    }

                    else Debugger.Break();
                }

                Array.Clear(state.Buffer, 0, state.Buffer.Length);

                _standardOutput.BaseStream.BeginRead(
                    _outputBuffer, 0,
                    _outputBuffer.Length,
                    _outputReady,
                    _outputState
                    );
            }
        }
예제 #4
0
 protected virtual void OnNotificationReceived(MsgPackNotificationEventArgs e)
 {
     MsgPackNotificationEventHandler handler = NotificationReceived;
     if (handler != null)
     {
         handler(this, e);
     }
 }
예제 #5
0
        protected virtual void OnNotificationReceived(object sender, MsgPackNotificationEventArgs e)
        {
            var handler = NotificationReceived;

            handler?.Invoke(this, e);
        }
예제 #6
0
        /// <summary>
        /// Gets executed if BeginRead() has red some data
        /// </summary>
        /// <param name="ar">Async Result</param>
        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();

                    // Response message has 4 items in the array
                    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 });
                    }

                    // Notification message has 3 items in the array
                    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
                    );
            }
        }