diff --git a/MaterialDeck.js b/MaterialDeck.js
index 5a4c6b6..50f151e 100644
--- a/MaterialDeck.js
+++ b/MaterialDeck.js
@@ -30,7 +30,7 @@ var enableModule;
//Websocket variables
let ip = "localhost"; //Ip address of the websocket server
-let port = "3003"; //Port of the websocket server
+let port = "3001"; //Port of the websocket server
var ws; //Websocket variable
let wsOpen = false; //Bool for checking if websocket has ever been opened => changes the warning message if there's no connection
let wsInterval; //Interval timer to detect disconnections
@@ -41,11 +41,20 @@ let WSconnected = false;
*
* @param {*} msg Message received
*/
-async function analyzeWSmessage(msg,passthrough = false){
+async function analyzeWSmessage(msg){
if (enableModule == false) return;
const data = JSON.parse(msg);
+ //console.log("Received",data);
+
+ if (data.type == "connected" && data.data == "SD"){
+ console.log("streamdeck connected to server");
+ }
+
+
+
+
if (data == undefined || data.payload == undefined) return;
- //console.log("Received",data);
+
const action = data.action;
const event = data.event;
const context = data.context;
@@ -114,11 +123,10 @@ async function analyzeWSmessage(msg,passthrough = false){
*/
function startWebsocket() {
//ip = localhost;
- ws = new WebSocket('ws://'+ip+':'+port+'/1');
+ ws = new WebSocket('ws://'+ip+':'+port);
ws.onmessage = function(msg){
//console.log(msg);
-
analyzeWSmessage(msg.data);
clearInterval(wsInterval);
wsInterval = setInterval(resetWS, 5000);
@@ -128,10 +136,16 @@ function startWebsocket() {
WSconnected = true;
ui.notifications.info("Material Deck "+game.i18n.localize("MaterialDeck.Notifications.Connected") +": "+ip+':'+port);
wsOpen = true;
- let msg = {
- type: "Foundry"
+ const msg = {
+ target: "server",
+ module: "MD"
}
ws.send(JSON.stringify(msg));
+ const msg2 = {
+ target: "SD",
+ type: "init"
+ }
+ ws.send(JSON.stringify(msg2));
clearInterval(wsInterval);
wsInterval = setInterval(resetWS, 5000);
}
diff --git a/changelog.md b/changelog.md
index d6379f7..f152a9c 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,4 +1,13 @@
# Changelog Material Deck Module
+### v0.8.6 - 18-11-2020
+
+- Added support for the new Material Server app
+
+
+Compatible server app and SD plugin:
+Material Server v1.0.0: https://github.com/CDeenen/MaterialServer/releases
+SD plugin v0.7.3: https://github.com/CDeenen/MaterialDeck_SD/releases
+
### v0.8.5 - 17-11-2020
- Added 'Display Icon' to Macro action
diff --git a/lang/en.json b/lang/en.json
index 113bb18..5f19339 100644
--- a/lang/en.json
+++ b/lang/en.json
@@ -1,6 +1,6 @@
{
- "MaterialDeck.Notifications.Disconnected": "Disconnected from mdServer, attempting to reconnect",
- "MaterialDeck.Notifications.ConnectFail": "Can't connect to mdServer, retrying",
+ "MaterialDeck.Notifications.Disconnected": "Disconnected from Material Server, attempting to reconnect",
+ "MaterialDeck.Notifications.ConnectFail": "Can't connect to Material Server, retrying",
"MaterialDeck.Notifications.Connected": "Connected",
"MaterialDeck.Sett.Enable": "Enable module",
diff --git a/module.json b/module.json
index 73b6dbd..010c243 100644
--- a/module.json
+++ b/module.json
@@ -2,7 +2,7 @@
"name": "MaterialDeck",
"title": "Material Deck",
"description": "",
- "version": "0.8.5",
+ "version": "0.8.6",
"author": "CDeenen",
"esmodules": [
"./MaterialDeck.js"
diff --git a/src/streamDeck.js b/src/streamDeck.js
index 8941441..b9ffdb9 100644
--- a/src/streamDeck.js
+++ b/src/streamDeck.js
@@ -144,6 +144,7 @@ export class StreamDeck{
}
}
let msg = {
+ target: "SD",
event: 'setTitle',
context: context,
payload: {
@@ -156,6 +157,7 @@ export class StreamDeck{
setColor(context,color = '#000000'){
let msg = {
+ target: "SD",
event: 'setIcon',
context: context,
url: '',
@@ -169,6 +171,7 @@ export class StreamDeck{
//var image = "data:image/svg+xml;charset=utf8,";
var json = {
+ target: "SD",
event: "setImage",
context: context,
payload: {
@@ -199,6 +202,7 @@ export class StreamDeck{
split = split[0].split(' ');
if (split[0] == 'fas' || split[0] == 'far' || split[0] == 'fal' || split[0] == 'fad') format = 'icon';
let msg = {
+ target: "SD",
event: 'setIcon',
context: context,
url: src,
@@ -217,6 +221,7 @@ export class StreamDeck{
setState(state,context,action){
let msg = {
+ target: "SD",
event: 'setStateCustom',
context: context,
action: action,
@@ -230,12 +235,13 @@ export class StreamDeck{
if (action == 'playlistcontrol')
profile = 'MaterialDeck-Playlist'
var json = {
- "source": 1,
- "event": "switchToProfile",
- "context": this.pluginId,
- "device": device,
- "payload": {
- "profile": profile
+ target: "SD",
+ source: 1,
+ event: "switchToProfile",
+ context: this.pluginId,
+ device: device,
+ payload: {
+ profile: profile
}
};
MODULE.sendWS(JSON.stringify(json));