From d0ad279d3330791e7f2800bcd852d6505b6e9043 Mon Sep 17 00:00:00 2001 From: Chris Marsh Date: Tue, 27 Jun 2017 13:19:36 -0700 Subject: [PATCH] pipe names --- test-rpc-server/rpc-message.js | 2 +- test-rpc-server/rpc-server.js | 9 ++++++--- test-rpc-server/test-client.js | 16 ++++++++++++---- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/test-rpc-server/rpc-message.js b/test-rpc-server/rpc-message.js index 0508b83..c0b1405 100644 --- a/test-rpc-server/rpc-message.js +++ b/test-rpc-server/rpc-message.js @@ -18,7 +18,7 @@ module.exports = class RpcMessage { try { return JSON.parse(msg); } catch(e) { - return null; + return {}; } } }; diff --git a/test-rpc-server/rpc-server.js b/test-rpc-server/rpc-server.js index 67933e7..83f3362 100644 --- a/test-rpc-server/rpc-server.js +++ b/test-rpc-server/rpc-server.js @@ -4,17 +4,20 @@ const RpcMessage = require('./rpc-message'); console.log('Start up'); let PipePrefix; +let PipePostfix; if (process.platform == 'win32') { - PipePrefix = "\\\\.\\pipe\\"; + PipePrefix = '\\\\.\\pipe\\'; + PipePostfix = ''; } else { PipePrefix = "/tmp"; + PipePostfix = '.pipe'; } -const PipePath = PipePrefix + "DiscordRpcServer"; +const PipePath = PipePrefix + "DiscordRpcServer" + PipePostfix; var server = net.createServer(function(stream) { - console.log('Server: on connection') + console.log('Server: on connection'); stream.on('data', function(data) { const msgObj = RpcMessage.deserialize(data); diff --git a/test-rpc-server/test-client.js b/test-rpc-server/test-client.js index 44f00bc..7600404 100644 --- a/test-rpc-server/test-client.js +++ b/test-rpc-server/test-client.js @@ -1,10 +1,18 @@ const net = require('net'); const RpcMessage = require('./rpc-message'); -var PIPE_NAME = "DiscordRpcServer"; -var PIPE_PATH = "\\\\.\\pipe\\" + PIPE_NAME; +let PipePrefix; +let PipePostfix; +if (process.platform == 'win32') { + PipePrefix = '\\\\.\\pipe\\'; + PipePostfix = ''; +} +else { + PipePrefix = "/tmp"; + PipePostfix = '.pipe'; +} -const msg = new RpcMessage(); +const PipePath = PipePrefix + "DiscordRpcServer" + PipePostfix; function sendMesg(testUpdatesToSend, stream) { const msgObj = { @@ -24,7 +32,7 @@ function sendMessageLoop(testUpdatesToSend, interval, stream) { } } -const client = net.connect(PIPE_PATH, function(stream) { +const client = net.connect(PipePath, function(stream) { console.log('Client: on connection'); sendMessageLoop(5, 3000, client);