@@ -145,7 +145,7 @@ private static void NetcodeServer()
145145 server . Dispose ( ) ;
146146 }
147147
148- public static string SendResponse ( HttpListenerRequest request , HttpListenerResponse response )
148+ public static Tuple < int , byte [ ] > SendResponse ( HttpListenerRequest request , HttpListenerResponse response )
149149 {
150150 if ( request . Url . AbsolutePath == "/" )
151151 {
@@ -155,7 +155,7 @@ public static string SendResponse(HttpListenerRequest request, HttpListenerRespo
155155 var indexPath = Path . Combine ( new FileInfo ( asmPath ) . DirectoryName , "index.htm" ) ;
156156 using ( var reader = new StreamReader ( indexPath ) )
157157 {
158- return reader . ReadToEnd ( ) . Replace ( "__PROTOCOL__" , isServerIpv4 ? "ipv4" : "ipv6" ) ;
158+ return new Tuple < int , byte [ ] > ( 200 , Encoding . UTF8 . GetBytes ( reader . ReadToEnd ( ) . Replace ( "__PROTOCOL__" , isServerIpv4 ? "ipv4" : "ipv6" ) ) ) ;
159159 }
160160 }
161161
@@ -167,7 +167,7 @@ public static string SendResponse(HttpListenerRequest request, HttpListenerRespo
167167 var indexPath = Path . Combine ( new FileInfo ( asmPath ) . DirectoryName , "basic.htm" ) ;
168168 using ( var reader = new StreamReader ( indexPath ) )
169169 {
170- return reader . ReadToEnd ( ) . Replace ( "__PROTOCOL__" , isServerIpv4 ? "ipv4" : "ipv6" ) ;
170+ return new Tuple < int , byte [ ] > ( 200 , Encoding . UTF8 . GetBytes ( reader . ReadToEnd ( ) . Replace ( "__PROTOCOL__" , isServerIpv4 ? "ipv4" : "ipv6" ) ) ) ;
171171 }
172172 }
173173
@@ -183,10 +183,24 @@ public static string SendResponse(HttpListenerRequest request, HttpListenerRespo
183183 0x1122334455667788L ,
184184 0 ,
185185 _privateKey ) ;
186- return Convert . ToBase64String ( token ) ;
186+ return new Tuple < int , byte [ ] > ( 200 , Encoding . UTF8 . GetBytes ( Convert . ToBase64String ( token ) ) ) ;
187187 }
188188
189- return "404 not found" ;
189+ if ( request . Url . AbsolutePath == "/netcode-support.xpi" )
190+ {
191+ response . ContentType = "application/x-xpinstall" ;
192+
193+ var asmPath = Assembly . GetExecutingAssembly ( ) . Location ;
194+ var xpiPath = Path . Combine ( new FileInfo ( asmPath ) . DirectoryName , "netcodeio_support_self_dist-0.1.5-fx.xpi" ) ;
195+ using ( var reader = new FileStream ( xpiPath , FileMode . Open , FileAccess . Read , FileShare . Read ) )
196+ {
197+ var b = new byte [ reader . Length ] ;
198+ reader . Read ( b , 0 , b . Length ) ;
199+ return new Tuple < int , byte [ ] > ( 200 , b ) ;
200+ }
201+ }
202+
203+ return new Tuple < int , byte [ ] > ( 404 , Encoding . UTF8 . GetBytes ( "404 not found" ) ) ;
190204 }
191205 }
192206}
0 commit comments