mirror of
https://github.com/yuzu-emu/discord-rpc.git
synced 2024-11-27 21:44:18 +01:00
pipe names
This commit is contained in:
parent
8e13ed2a63
commit
d0ad279d33
@ -18,7 +18,7 @@ module.exports = class RpcMessage {
|
||||
try {
|
||||
return JSON.parse(msg);
|
||||
} catch(e) {
|
||||
return null;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user