Skip to content

Commit

Permalink
create http server
Browse files Browse the repository at this point in the history
  • Loading branch information
xieguigang committed Nov 1, 2024
1 parent 8720aec commit defc029
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Rscript.vb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Public Module RscriptEngine
''' </summary>
''' <param name="port"></param>
<ExportAPI("listen")>
Public Sub listen(Optional port As Integer = 321)
Public Sub listen(Optional port As Integer = 321, Optional vscode_clr As String = Nothing)
Call New LanguageServer(port).Listen()
End Sub

Expand Down
26 changes: 23 additions & 3 deletions src/lsp/LanguageServer.vb
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
Public Class LanguageServer
Imports System.Reflection
Imports Flute.Http
Imports Flute.Http.Core
Imports Flute.Http.Core.Message
Imports Flute.Http.FileSystem
Imports Microsoft.VisualBasic.ApplicationServices

Public Class LanguageServer : Implements IAppHandler

ReadOnly vscode As FileSystem
ReadOnly http As HttpSocket

Sub New(port As Integer)
Sub New(port As Integer, Optional vscode_clr As String = Nothing)
If vscode_clr.FileExists(ZERO_Nonexists:=True) Then
vscode = New FileSystem(FindResource(Assembly.LoadFrom(vscode_clr.GetFullPath)))
End If

http = New HttpDriver().HttpMethod("get", Me).GetSocket(port)
End Sub

Public Sub Listen()
Private Shared Function FindResource(asm As Assembly) As IFileSystemEnvironment

End Function

Private Sub AppHandler(request As HttpRequest, response As HttpResponse) Implements IAppHandler.AppHandler

End Sub

Public Sub Listen()
Call http.Run()
End Sub
End Class

0 comments on commit defc029

Please sign in to comment.