Skip to content

Instantly share code, notes, and snippets.

@RElesgoe
Created October 31, 2015 10:47
Show Gist options
  • Save RElesgoe/36c1f89aa9d294139270 to your computer and use it in GitHub Desktop.
Save RElesgoe/36c1f89aa9d294139270 to your computer and use it in GitHub Desktop.
PvPGN Connector
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('window.html', {
'outerBounds': {
'width': 400,
'height': 500
}
});
});
{
"manifest_version": 2,
"name": "PvPGN Connector",
"description": "test",
"version": "1.0.0",
"app": {
"background": {
"scripts": ["connector.js"]
}
},
"sockets": {
"udp": {
// Permission for chrome.sockets.udp.send:
// The application is allowed to send udp packets
// to any host:6112 combination.
"send": "*:6112"
},
"tcp": {
// Permission for chrome.sockets.tcp.connect:
// The application is allowed to connect to
// any server port 6112.
"connect": "*:6112"
},
"tcpServer": {
// Permission for chrome.sockets.tcpServer.listen:
// The application is allowed to accept new client
// connections on the local address at port 6112.
"listen": "127.0.0.1:6112"
}
}
}
chrome.sockets.tcp.create({}, function(createInfo)
{
chrome.sockets.tcp.connect(createInfo.socketId, "127.0.0.1", 6112, function(result) {
if (result < 0)
{
console.log("Connection failed");
}
});
var buffer = new ArrayBuffer(1);
var init_protocol_bnet = new Int8Array(buffer);
init_protocol_bnet.set(0x01);
chrome.sockets.tcp.send(createInfo.socketId, init_protocol_bnet, function(sendInfo) {
if (sendInfo.resultCode < 0)
{
console.log("Send init failed");
}
});
});
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div>Hello, world!</div>
<script src="script.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment