WebSocket server properties exposed (#168)
* Added support to AllowPort forwarding, SecureConnection on any port on the server and assign SSL certificate with a base64 string * remove unused namespaces
This commit is contained in:
Родитель
251d7e1cad
Коммит
d11b679f9a
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
using WebSocketSharp.Server;
|
||||
|
@ -15,6 +16,8 @@ namespace Netcode.Transports.WebSocket
|
|||
public string ConnectAddress = "127.0.0.1";
|
||||
public ushort Port = 7777;
|
||||
public bool SecureConnection = false;
|
||||
public bool AllowForwardedRequest;
|
||||
public string CertificateBase64String;
|
||||
|
||||
public override ulong ServerClientId => 0;
|
||||
|
||||
|
@ -122,9 +125,15 @@ namespace Netcode.Transports.WebSocket
|
|||
{
|
||||
throw new InvalidOperationException("Socket already started");
|
||||
}
|
||||
|
||||
WebSocketServer = new WebSocketServer(Port);
|
||||
|
||||
WebSocketServer = new WebSocketServer(Port, SecureConnection);
|
||||
WebSocketServer.AllowForwardedRequest = AllowForwardedRequest;
|
||||
WebSocketServer.AddWebSocketService<WebSocketServerConnectionBehavior>("/netcode");
|
||||
if (!string.IsNullOrEmpty(CertificateBase64String))
|
||||
{
|
||||
var bytes = Convert.FromBase64String(CertificateBase64String);
|
||||
WebSocketServer.SslConfiguration.ServerCertificate = new X509Certificate2(bytes);
|
||||
}
|
||||
WebSocketServer.Start();
|
||||
|
||||
IsStarted = true;
|
||||
|
|
Загрузка…
Ссылка в новой задаче