Skip to content

Commit

Permalink
Merge pull request #4 from nova-ind/master
Browse files Browse the repository at this point in the history
uwu
  • Loading branch information
novafurry authored Aug 15, 2024
2 parents 2ebbc5b + 85093ab commit cbbc81c
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"window.commandCenter": false,
"workbench.layoutControl.enabled": false,
"workbench.statusBar.visible": false
"workbench.statusBar.visible": false,
"liveServer.settings.multiRootWorkspaceName": "dng"
}
84 changes: 75 additions & 9 deletions assets/code/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,21 +541,87 @@ var app = {
runs: true,
name: 'Cast',
icon: './assets/img/systemIcons/cast.svg',
init: async function(){
const win = tk.mbw('Cast', '300px', 'auto', false, true, true, undefined, './assets/img/systemIcons/cast.svg');
init: async function(id = false, username = "NovaOS User"){
var p;
const win = tk.mbw('Cast', '300px', 'auto', false, true, true, "ncast", './assets/img/systemIcons/cast.svg');
win.win.id= "ncast"
tk.mkel('h1',[], "Cast", win.main)
tk.p("enter the deskID of another user with the cast app open to share your screen.", "", win.main)
var recepient = tk.c("input", win.main, "i1")
var send = tk.cb("b1", "Start", function(){},win.main)
recepient.required = true
var send = tk.cb("b1", "Start", async function(){
var conn = peer.connect(id)
conn.on('open', async function() {
// Receive messages

// Send messages
var castpeer = new Peer(await fs.read('/user/info/deskid')+"-cast")
castpeer.on('open', async function (id) {
conn.send({name:"osAppConnect-cast",id:await fs.read('/system/deskid'),uname:await fs.read('/user/info/name') || "NovaOS User"});

})
castpeer.on('connection', (conn) => {
conn.on('data', (data) => {
console.log(data)
});
});
});
},win.main)
var stop = tk.cb("b1", "Stop", function(){},win.main)
stop.style.display = "none"
var ic = tk.mkel("div", ["notif"],"",win.main)
tk.mkel('b',[],"Incoming Request<br>",ic)
var req = tk.mkel('span',[],"ID: 8008135<br>",ic)
var ac = tk.cb("b1 smallb", "Accept", function(){},ic)
var de = tk.cb("b1 smallb", "Deny", function(){},ic)
console.log(id)
if(id !== false){
var ic = tk.mkel("div", ["notif"],"",win.main)
ic.id = "ncastNotizone"
tk.mkel('b',[],"Incoming Request<br>",ic)
var req = tk.mkel('span',[],`ID: ${id.toString()}<br>Username: ${username.toString()}<br>`,ic)
var ac = tk.cb("b1 smallb", "Accept", async function(){
p = new Peer(await fs.read('/system/deskid')+"-cast");
p.on('open', function(id) {
console.log('My peer ID is: ' + id);
var c = p.connect(id+"-cast");
c.on('open', function() {
// Receive messages
c.on('data', function(data) {
console.log('Received', data);
});

// Send messages
c.send('connAccept');
});

});
ui.dest(ic)
const recv = tk.mbw(`Cast Reciever: ${username.toString()}#${id.toString()}`, '850px', '490px', false, true, true, './assets/img/systemIcons/cast.svg')
const video = tk.c('video', recv.main)
video.setAttribute("controls", "yes")
video.style.width = "100%"
video.style.height = "100%"
const stop = tk.cb('b4', "Stop", function(){}, recv.title.children[0])
p.on('call', function(call) {
// Answer the call, providing our mediaStream
call.answer(null);
call.on('stream', function(stream) {
// `stream` is the MediaStream of the remote peer.
// Here you'd add it to an HTML video/canvas element.
video.srcObject = stream;
video.play()
});
});
},ic)
var de = tk.cb("b1 smallb", "Deny", function(){ui.dest(ic)},ic)
}
},
connection: async function (id, uname) {
if(document.querySelector("#ncast")){
document.querySelector("#ncast .winb.red").click()
app.cast.init(id, uname)
}
else{
app.cast.init(id, uname)
}
}
},
}

app.cast.init()
app.cast.connection(30012)
10 changes: 10 additions & 0 deletions assets/code/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ function handleData(conn, data) {
addcall(data.file, callid);
console.log('<i> bounced names');
setInterval(function () { masschange('callname', data.file); }, 300);
} else if (data.name.startsWith("osAppConnect")){
if(app.hasOwnProperty(data.name.split("osAppConnect-")[1])){
if(app[data.name.split("osAppConnect-")[1]].hasOwnProperty("connection")){
app[data.name.split("osAppConnect-")[1]].connection(data.id, data.uname)
} else {
wm.notif(`${data.uname} (#${data.id}) attempted to connect using ${data.name.split("osAppConnect-")[1]}, but the app does not support recieving. Please confirm you are using the same app and version as the other party.`, `Networking`)
}
} else {
wm.notif(`${data.uname} (#${data.id}) attempted to connect using ${data.name.split("osAppConnect-")[1]}, but the required app was not found. Please confirm you are using the same app as the other party.`, `Networking`)
}
} else {
recb = data.file;
recn = data.name;
Expand Down
2 changes: 1 addition & 1 deletion assets/code/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ var tk = {
}
if (quit === true) {
closeButton.classList.add('red');
closeButton.addEventListener('mousedown', function () {
closeButton.addEventListener('click', function () {
ui.dest(windowDiv, 100);
ui.dest(tbn, 100);
});
Expand Down
2 changes: 1 addition & 1 deletion assets/code/wm.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ ${cont}`;
dest(win);
}
} else {
log(`<!> Error closing window. Window: ${div} - Button: ${document.getElementById(win)}`);
console.log(`<!> Error closing window. Window: ${div} - Button: ${document.getElementById(win)}`);
}
},
/**
Expand Down

0 comments on commit cbbc81c

Please sign in to comment.