Skip to content

Instantly share code, notes, and snippets.

@FlowingSPDG
Last active August 9, 2020 06:29
Show Gist options
  • Save FlowingSPDG/df83fb99b38737af0c447e4bcaa333fd to your computer and use it in GitHub Desktop.
Save FlowingSPDG/df83fb99b38737af0c447e4bcaa333fd to your computer and use it in GitHub Desktop.
vMix VB.NET Example
Dim root As String = "c:\wwwroot\" ' doc root
Dim prefix As String = "http://localhost:8888/"
Dim listener As New HttpListener()
listener.Prefixes.Add(prefix)
listener.Start()
While (True)
Dim context As HttpListenerContext = listener.GetContext()
Dim req As HttpListenerRequest = context.Request
Dim res As HttpListenerResponse = context.Response
Console.WriteLine(req.RawUrl)
' リクエストされたURLからファイルのパスを求める
Dim path As String = root & req.RawUrl.Replace("/", "\\")
' ファイルが存在すればレスポンス・ストリームに書き出す
If File.Exists(path) Then
Dim content() As Byte = File.ReadAllBytes(path)
res.OutputStream.Write(content, 0, content.Length)
End If
res.Close()
End While
'ダウンロード元のURL
'Specify download source url
Dim port As Int32 = 8881
Dim url As String = String.Format("http://localhost:{0}/api",8881)
'WebClientを作成
'Create WebClient
Dim wc As New System.Net.WebClient()
'文字コードを指定
'Specfy character code
wc.Encoding = System.Text.Encoding.UTF8
'データを文字列としてダウンロードする
'Download data as string
Dim source As String = wc.DownloadString(url)
'後始末
'Dispose
wc.Dispose()
'XMLデータに復元する
'Restore to XML
dim x as new system.xml.xmldocument
x.loadxml(source)
Dim versionElem as system.xml.XmlNode = x.SelectSingleNode("vmix/version")
Dim vmix_version as String = versionElem.InnerText()
Console.WriteLine(String.Format("Current vmix version is : {0}", vmix_version))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment