Beispiel #1
0
        protected virtual void OnNotificationReceived(MsgPackEventArgs e)
        {
            MsgPackNotificationEventHandler handler = NotificationReceived;

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

            var list = msgPackEventArgs.Result.AsList();
            NeovimRedrawEventArgs args = new NeovimRedrawEventArgs();
            args.Functions = list;
            OnRedraw(args);
        }
Beispiel #3
0
        /// <summary>
        /// Fires a redraw event after getting a notification from the MsgPackIO class
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="msgPackEventArgs"></param>
        private void OnNotificationReceived(object sender, MsgPackEventArgs msgPackEventArgs)
        {
            if (msgPackEventArgs.Function != "redraw")
            {
                return;
            }

            var list = msgPackEventArgs.Result.AsList();
            NeovimRedrawEventArgs args = new NeovimRedrawEventArgs();

            args.Functions = list;
            OnRedraw(args);
        }
Beispiel #4
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];

                        MsgPackEventArgs args = new MsgPackEventArgs();
                        args.Function = func;
                        args.Result = res;
                        OnNotificationReceived(args);
                    }

                    else Debugger.Break();
                }

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

                _standardOutput.BaseStream.BeginRead(
                    _outputBuffer, 0,
                    _outputBuffer.Length,
                    _outputReady,
                    _outputState
                    );
            }
        }
Beispiel #5
0
 protected virtual void OnNotificationReceived(MsgPackEventArgs e)
 {
     MsgPackNotificationEventHandler handler = NotificationReceived;
     if (handler != null)
     {
         handler(this, e);
     }
 }
Beispiel #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();

                    // 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];

                        MsgPackEventArgs args = new MsgPackEventArgs();
                        args.Function = func;
                        args.Result   = res;
                        OnNotificationReceived(args);
                    }

                    else
                    {
                        Debugger.Break();
                    }
                }

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

                _standardOutput.BaseStream.BeginRead(
                    _outputBuffer, 0,
                    _outputBuffer.Length,
                    _outputReady,
                    _outputState
                    );
            }
        }