Skip to content

Instantly share code, notes, and snippets.

@daxfohl
Last active October 18, 2019 14:11
Show Gist options
  • Save daxfohl/2255c63d0095d242a2ee45c81592d348 to your computer and use it in GitHub Desktop.
Save daxfohl/2255c63d0095d242a2ee45c81592d348 to your computer and use it in GitHub Desktop.
using System;
using System.Text;
namespace ConsoleApp6
{
class Program
{
static void Main(string[] args)
{
while (true)
{
var lenStr = Console.ReadLine();
var contentLength = int.Parse(lenStr.Substring(16));
Console.ReadLine();
var sb = new StringBuilder();
for(var j = 0; j < contentLength; ++j)
{
sb.Append((char)Console.Read());
}
var req = sb.ToString();
string response = null;
if (req.Contains("\"initialize\""))
{
response = "{\"jsonrpc\":\"2.0\",\"id\":0,\"result\":{\"capabilities\":{\"textDocumentSync\":1,\"completionProvider\":{\"resolveProvider\":true}}}}";
}
else if (req.Contains("\"initialized\""))
{
response = "{\"jsonrpc\":\"2.0\",\"method\":\"window/showMessage\",\"params\":{\"type\":1,\"message\":\"Hello from server\"}}";
}
if(response != null)
{
Console.Write($"Content-Length: {response.Length}\r\n\r\n{response}");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment