var socketId = 0;
|
|
chrome.app.runtime.onLaunched.addListener(function() {
|
|
if (socketId) {
|
|
console.log("close socket " +socketId);
|
|
chrome.sockets.tcpServer.close(socketId);
|
|
socketId = 0;
|
|
}
|
|
chrome.app.window.create('main.html', {
|
|
id: "mainwin",
|
|
innerBounds: {
|
|
width: 670,
|
|
height: 350,
|
|
minWidth: 670,
|
|
minHeight: 350
|
|
}
|
|
});
|
|
})
|
|
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse)
|
|
{
|
|
socketId = request.socketId;
|
|
|
|
});
|
|
chrome.runtime.onSuspend.addListener(function() {
|
|
if(socketId) {
|
|
chrome.sockets.tcpServer.close(socketId);
|
|
socketId = 0;
|
|
}
|
|
});
|
|
|