pipe names
This commit is contained in:
parent
8e13ed2a63
commit
d0ad279d33
3 changed files with 19 additions and 8 deletions
|
@ -18,7 +18,7 @@ module.exports = class RpcMessage {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(msg);
|
return JSON.parse(msg);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
return null;
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,17 +4,20 @@ const RpcMessage = require('./rpc-message');
|
||||||
console.log('Start up');
|
console.log('Start up');
|
||||||
|
|
||||||
let PipePrefix;
|
let PipePrefix;
|
||||||
|
let PipePostfix;
|
||||||
if (process.platform == 'win32') {
|
if (process.platform == 'win32') {
|
||||||
PipePrefix = "\\\\.\\pipe\\";
|
PipePrefix = '\\\\.\\pipe\\';
|
||||||
|
PipePostfix = '';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PipePrefix = "/tmp";
|
PipePrefix = "/tmp";
|
||||||
|
PipePostfix = '.pipe';
|
||||||
}
|
}
|
||||||
|
|
||||||
const PipePath = PipePrefix + "DiscordRpcServer";
|
const PipePath = PipePrefix + "DiscordRpcServer" + PipePostfix;
|
||||||
|
|
||||||
var server = net.createServer(function(stream) {
|
var server = net.createServer(function(stream) {
|
||||||
console.log('Server: on connection')
|
console.log('Server: on connection');
|
||||||
|
|
||||||
stream.on('data', function(data) {
|
stream.on('data', function(data) {
|
||||||
const msgObj = RpcMessage.deserialize(data);
|
const msgObj = RpcMessage.deserialize(data);
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const RpcMessage = require('./rpc-message');
|
const RpcMessage = require('./rpc-message');
|
||||||
|
|
||||||
var PIPE_NAME = "DiscordRpcServer";
|
let PipePrefix;
|
||||||
var PIPE_PATH = "\\\\.\\pipe\\" + PIPE_NAME;
|
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) {
|
function sendMesg(testUpdatesToSend, stream) {
|
||||||
const msgObj = {
|
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');
|
console.log('Client: on connection');
|
||||||
|
|
||||||
sendMessageLoop(5, 3000, client);
|
sendMessageLoop(5, 3000, client);
|
||||||
|
|
Loading…
Reference in a new issue