1
0
Fork 0

Update connection to be ip address agnostic

This commit is contained in:
Starbeamrainbowlabs 2017-05-04 19:53:38 +01:00
parent 0498b5ad9a
commit 19412e4361
3 changed files with 20 additions and 16 deletions

View File

@ -5,23 +5,26 @@ namespace Nibriboard.Client
{ {
public class ClientSettings public class ClientSettings
{ {
[JsonIgnore] /// <summary>
public bool SecureWebsocket = false; /// Whether the WebSocket is secure.
[JsonIgnore] /// </summary>
public int WebsocketPort; public bool SecureWebSocket = false;
[JsonIgnore]
public string WebsocketHost = "localhost"; /// <summary>
[JsonIgnore] /// The protocol to use over the WebSocket.
public string WebsocketPath; /// </summary>
public string WebsocketProtocol = "RippleLink";
public int WebSocketPort;
public string WebSocketHost = "localhost";
public string WebSocketPath;
public string WebsocketUri { public string WebsocketUri {
get { get {
return (SecureWebsocket ? "wss" : "ws") + $"://{WebsocketHost}:{WebsocketPort}{WebsocketPath}"; return (SecureWebSocket ? "wss" : "ws") + $"://{WebSocketHost}:{WebSocketPort}{WebSocketPath}";
} }
} }
public string WebsocketProtocol = "RippleLink";
public ClientSettings() public ClientSettings()
{ {

View File

@ -148,7 +148,7 @@ class BoardWindow extends EventEmitter
* This mainly consists of establishing the RippleLink connection to the server. * This mainly consists of establishing the RippleLink connection to the server.
*/ */
setup() { setup() {
this.rippleLink = new RippleLink(this.settings.WebsocketUri, this); this.rippleLink = new RippleLink(`ws${this.settings.SecureWebSocket ? "s" : ""}://${location.host}/${this.settings.WebSocketPath}`, this);
this.rippleLink.on("connect", (function(event) { this.rippleLink.on("connect", (function(event) {
// Send the handshake request // Send the handshake request

View File

@ -31,9 +31,10 @@ namespace Nibriboard
Port = inPort; Port = inPort;
clientSettings = new ClientSettings() { clientSettings = new ClientSettings() {
WebsocketHost = "192.168.0.56", SecureWebSocket = false,
WebsocketPort = Port, WebSocketHost = "192.168.0.56",
WebsocketPath = "/RipplespaceLink" WebSocketPort = Port,
WebSocketPath = "/RipplespaceLink"
}; };
// HTTP Server setup // HTTP Server setup
@ -59,7 +60,7 @@ namespace Nibriboard
clientManagerCanceller.Token clientManagerCanceller.Token
); );
httpServer.AddWebSocketRequestHandler( httpServer.AddWebSocketRequestHandler(
clientSettings.WebsocketPath, clientSettings.WebSocketPath,
clientManager clientManager
); );