If I press a key on your pc, a sound plays on yours. Help!?
If I press a key on your pc, a sound plays on yours. Help!?
I don’t want to go into the reasons why, but I’m in need of a thing that will do what it says in the title. I could probably put something together in python, but ideally, something like a webpage that 2 people could go to, and do nothing more than put in a pairing code each. As simple as possible, but secure.
Does anyone have any thoughts about how this might be done?
Does anyone have any thoughts about how this might be done?
I made a deviantart page.
'....The baron is a gay old rogue with an eye for the ladies....'
'....The baron is a gay old rogue with an eye for the ladies....'
Re: If I press a key on your pc, a sound plays on yours. Hel
I think you got the title wrong.
I'd approach it differently depending on the amount of polish you want.
If no polish then I'd look at ITTT first, or even Scratch.
For a nice version, I'd build serverless on Azure on their free tier: a Python/Flask app serving some vanilla html.
I'd approach it differently depending on the amount of polish you want.
If no polish then I'd look at ITTT first, or even Scratch.
For a nice version, I'd build serverless on Azure on their free tier: a Python/Flask app serving some vanilla html.
- Little stoned kiwi
- Baaaaaa!

- Posts: 4598
- Joined: Mon Oct 27, 2003 6:05 am 0
- Location: Christchurch
Re: If I press a key on your pc, a sound plays on yours. Hel
If it runs in the browser, won't it have to retain context to register key presses?
If they think you're crude, go technical; if they think you're technical, go crude. I'm a very technical boy.
- gilesgoat
- Sheepie Whore

- Posts: 27259
- Joined: Wed Sep 03, 2003 7:54 am 0
- Location: Monfalcone, Italy
- Contact:
Re: If I press a key on your pc, a sound plays on yours. Hel
Interesting problem .. I am no huge expert of anything but "first look" makes me think "it needs a client-server architecture", something you can send a "message" from PC a to PC b ( and vice versa ) and make the PC play a sound when it receives it.
I don't know how it could be done "if both are logged into a same site" I mean "how can you send an 'event' to the other browser ?" as far as I know the HTML "transaction" ends the moment you finish your "GET" unless I suppose you have a "timer" that periodically refresh the page ?
It's not super difficult in CPP ( well it takes a little while ) to write a client/server small thing maybe sending an UDP message to/from another PC but it's abit of a PITA/overkill maybe ( or maybe not ).
[edit] - in the last 2 days, it does happen, I wrote ( yet another ) client-server thing between a PC and a Z80 thing running on a serial port "to exchange files and commands", a "window 1" simple protocol with CRC-8 and such, little problem is I wrote the "Client" on the PC only and the "Server" on the Z80 only and implies the two machines are phisically connected with an RS232 cable.
"Window 1" means "1 packet at the time" so "send packet/wait for ack/nack/timeout", if "nack/timeout re-send again up-to N retries, if retries > N then fail, something is wrong with the line/server".
But yeah in that case it's not even "full duplex" I mean the "Client" always goes "first" the "server" goes "second" but it would not take much to modify it.
It's .. very interesting to write that kind of SW ( and debug it ) ..
I don't know how it could be done "if both are logged into a same site" I mean "how can you send an 'event' to the other browser ?" as far as I know the HTML "transaction" ends the moment you finish your "GET" unless I suppose you have a "timer" that periodically refresh the page ?
It's not super difficult in CPP ( well it takes a little while ) to write a client/server small thing maybe sending an UDP message to/from another PC but it's abit of a PITA/overkill maybe ( or maybe not ).
[edit] - in the last 2 days, it does happen, I wrote ( yet another ) client-server thing between a PC and a Z80 thing running on a serial port "to exchange files and commands", a "window 1" simple protocol with CRC-8 and such, little problem is I wrote the "Client" on the PC only and the "Server" on the Z80 only and implies the two machines are phisically connected with an RS232 cable.
"Window 1" means "1 packet at the time" so "send packet/wait for ack/nack/timeout", if "nack/timeout re-send again up-to N retries, if retries > N then fail, something is wrong with the line/server".
But yeah in that case it's not even "full duplex" I mean the "Client" always goes "first" the "server" goes "second" but it would not take much to modify it.
It's .. very interesting to write that kind of SW ( and debug it ) ..
Giles the billy goat
"Baa"
"Baa"
Re: If I press a key on your pc, a sound plays on yours. Hel
Sounds to me like any IM app is pretty much equivalent.
Re: If I press a key on your pc, a sound plays on yours. Hel
Yeah, the problem with doing it through a website, is that clients connect to servers, but servers do not connect to clients.gilesgoat wrote:I don't know how it could be done "if both are logged into a same site" I mean "how can you send an 'event' to the other browser ?" as far as I know the HTML "transaction" ends the moment you finish your "GET" unless I suppose you have a "timer" that periodically refresh the page ?
You could write a web page where, with Javascript, it sends an AJAX request to the server when you press a key. And you can have users enter a "pairing code", then save a cookie on their machines to identify them / the conversation with an ID. Client cookies are sent with every request made to the server, and the server can look in its SQL database for that ID code and match up users with the same "pairing code".
But, once the server establishes that the key has been pressed, how does it send a message to the client to tell it to play a sound?
Well, it can't. That's not how HTTP is designed to work - clients "request" things of servers, who send back "responses" - and it also wouldn't work practically, as your router firewall would reject any unauthorised incoming packets, and your browser's not listening for them either. Like, you can't force a packet through.
As giles says, you could have a bit of Javascript that periodically sends an AJAX request to the server, essentially asking it "has the key been pressed yet?", "has the key been pressed yet?" over and over, until the server finally says "yes". But that'd be very spammy of bandwidth, to be constantly polling for an answer. And if you have it only checking every 10 seconds, then the key could be pressed and then you don't find out about it until up to 10 seconds later. If you check every second, then there's only a 1 second delay, but that's spamming the connection with 10 times as many "are we there yet?" messages in the meantime.
So I'm also thinking it'd be easier to write a program that can send and receive UDP packets on a particular port - which is, in essence, what IM programs basically do - to send data back and forth. Because, with a program, you can actually call "accept", which waits for incoming packets. You'd have to clear a path through the firewall for traffic on that port and now each other's IP addresses.
(Indeed, if I coded something like that up in C / C++, then it'd probably be harder to code the "playing a sound" bit - certainly in a portable way - than the simple network logic of passing packets back and forth.)
The problem is servers generally can't send out packets. They accept them and respond to them. But they can't just send an unexpected packet at some device - it will just bounce off the firewall and, even if it didn't, then there's nothing there listening to pick up that packet anyway.
(Firewalls only let servers respond to requests, because they actually track that a packet was sent from client -> server, then note the IP addresses and ports, to just let the response packet back through the firewall. So the client has to start the conversation, as that's how firewalls detect if an incoming packet was "solicited" or not. The client sending out a packet to the server is what gets tracked to allow a packet coming back from that server through the firewall. Unsolicited packets will just bounce off the firewall, which'll flatly reject them.)
I guess it depends on how much tolerance you have for delay between key press and the sound playing (and if you've ever been on the phone to someone and then also sent them an email then you probably realise that communications are, in fact, delayed but you usually don't notice this, because the first you hear about it is when the notification appears on your machine - but if you have that second means of instant communication, the phone, then you can literally do the "I'm pressing 'send' now" and then you could be waiting 10 to 20 seconds before they say "okay, it's come through". Or it could happen almost immediately. There's more variance there than people realise, but normally there's no way to tell, so no-one much notices). And how much you care about being "spammy" with the AJAX requests.
Because then, yeah, you could have a web page that accepts a "pairing code" then you submit. The server then, in response, checks the database for another record with the same "pairing code". If it can't find one, then this device has "paired" first and it creates such a record. So when the second server enters the "pairing code" and it looks in the database, then the record is there and we've found our pairing.
Once you've established all this, you can set a cookie on the user's machine with some kind of randomly generated "session ID" and "client ID". Cookies are always sent with every request to that server, so when you have the cookie, you can look up those IDs in the database to get the user / session information.
Then you could have a button on the page that, when clicked, sends an AJAX request to the server. Included in that request is the "session ID" - so the server knows which "session" has been triggered - and the "client ID" - so we know who sent it (as we only want to send to the other person, not the sender).
The server can't send out packets, unfortunately. So, instead, the clients are periodically polling the server with an AJAX request ("has the button been pressed?" and the server says "no"). Then when the button is pressed, the server will answer "yes" to that question and the sound plays. Then you'd reset things - the server goes back to saying "no" again - so the sound only plays once and, well, you can hit the key and do it again, if you like.
It could be done, but it'd be clunky as hell over HTTP, as it's designed to only be client -> server and server responds. If you go beyond that, then firewalls will start stopping you doing anything. It's easier with code - an actual app - that can call "accept" and start waiting for incoming packets explicitly.
Which is why, you'll notice, things like Zoom or Skype or instant messaging tends to be implemented through an "app" you download on your machine. Like, you can go to the Zoom website but then it'll tell you to download the app. Because apps can send packets back and forth directly. HTML / HTTP requires "creative solutions" and is vastly more clunky for it.
"Words ought to be a little wild - for they are assaults of thought on the unthinking."
- John Maynard Keynes
- John Maynard Keynes
Re: If I press a key on your pc, a sound plays on yours. Hel
If I recall correctly in ICQ you could do that easily but just to initiate a conversation to see if the other party was there.Dio wrote:Sounds to me like any IM app is pretty much equivalent.
Would be trivial to do in Delphi with the client/server components supplied with it (I've just seen they've gone to the subscription model with outrageous prices, eeech, what a sad end for such a beautiful dev environment).
A bit more faffing around in C++. HTML would be a pain, you'd have to set up a web server on at least one end.
- zip accident
- Sheepie Whore

- Posts: 13928
- Joined: Sun Feb 20, 2005 1:58 pm 0
- Location: Bristol, UK
Re: If I press a key on your pc, a sound plays on yours. Hel
Why aren't telephones a way to do this? Voice over internet barely worked twenty years ago, by now it seems to be up and running.
"My way is the way of not fighting":- the book of Enter the Dragon.
- Ratsoap
- Baaaaaaa!

- Posts: 6344
- Joined: Fri Dec 19, 2003 1:46 pm 0
- Location: Back in Edinburgh
- Contact:
Re: If I press a key on your pc, a sound plays on yours. Hel
Websockets could do something like this I reckon.
Because fucking marketing cunts would never call a spade anything other than a Deluxe Easi-Shift Earth Movement Solution.
- gilesgoat
- Sheepie Whore

- Posts: 27259
- Joined: Wed Sep 03, 2003 7:54 am 0
- Location: Monfalcone, Italy
- Contact:
Re: If I press a key on your pc, a sound plays on yours. Hel
.. Amazing .. an embedding of an embedding of an emulation of a api over an api over ...Ratsoap wrote:Websockets could do something like this I reckon.
Basically yes ... "you get WINSOCK and you do the same in native CPP" ... which basically is "open a socket" put something into "listen mode", something else into "connect" once connection is established send a packet and receive it from the other side ..
Or alternatively you may think at something like this ...
Not to mention some of those "Arduino with wireless net thing" that you probably can get for 5 pounds each .. that probably is what is inside the other thing I just put a link of
Giles the billy goat
"Baa"
"Baa"
- gilesgoat
- Sheepie Whore

- Posts: 27259
- Joined: Wed Sep 03, 2003 7:54 am 0
- Location: Monfalcone, Italy
- Contact:
Re: If I press a key on your pc, a sound plays on yours. Hel
@KlaxonCow ... if it's checking every 10 second or even every 1 second .. "it's probably 100 times more optimized that ceratain shit I've seen" ...As giles says, you could have a bit of Javascript that periodically sends an AJAX request to the server, essentially asking it "has the key been pressed yet?", "has the key been pressed yet?" over and over, until the server finally says "yes". But that'd be very spammy of bandwidth, to be constantly polling for an answer. And if you have it only checking every 10 seconds, then the key could be pressed and then you don't find out about it until up to 10 seconds later. If you check every second, then there's only a 1 second delay, but that's spamming the connection with 10 times as many "are we there yet?" messages in the meantime.
"What shit ?" .. well .. "just write any native Android APP and fire up the native debugger" .. one of the first things you'll ask yourself is "WHY there's a 'filter' thing in the debugger window ?" .. the answer is "so you can theorectically filter and see ONLY the debug shit that YOUR applicantion does" ( via OutputDebug ("MyProg", ... ) with "MyProg" as filter ) ...
If you don't use filters .. look at THE CONSTANT AMOUNT OF SHIT THAT HAPPENS 10 times per second of what your Andorid phone is constantly doing with Google servers/sending shit back and for ALL THE TIME .. !!!
No no .. we are not surveilled 24/7 .. no .. it's all conspiracy theories .. no I cannot believe it .. sure it's all bollocks ?
... the answers are in your "debug output" window .. .. ...
Giles the billy goat
"Baa"
"Baa"
Re: If I press a key on your pc, a sound plays on yours. Hel
You can always buy yourself a faraday cage cover for your phone... made in China of coursegilesgoat wrote: No no .. we are not surveilled 24/7 .. no .. it's all conspiracy theories .. no I cannot believe it .. sure it's all bollocks ?
... the answers are in your "debug output" window .. .. ...
- zip accident
- Sheepie Whore

- Posts: 13928
- Joined: Sun Feb 20, 2005 1:58 pm 0
- Location: Bristol, UK
Re: If I press a key on your pc, a sound plays on yours. Hel
The issue is that then you can only connect when the cage is removed.noodles wrote:You can always buy yourself a faraday cage cover for your phone... made in China of coursegilesgoat wrote: No no .. we are not surveilled 24/7 .. no .. it's all conspiracy theories .. no I cannot believe it .. sure it's all bollocks ?
... the answers are in your "debug output" window .. .. ...No worries!
"My way is the way of not fighting":- the book of Enter the Dragon.
Re: If I press a key on your pc, a sound plays on yours. Hel
It is a wonder to consider whether, if Google and Apple's phones didn't keep "phoning home" every 3 microseconds, how much longer your phone battery might actually last...
(I did, many years ago, take a look at Android development - and I can confirm that, yes, the debug output does look like that, and that, yes, "Android Studio" is a pile of shit. Giles is prone to swear-y melodramatics on occasion, but he's not wrong.)
(I did, many years ago, take a look at Android development - and I can confirm that, yes, the debug output does look like that, and that, yes, "Android Studio" is a pile of shit. Giles is prone to swear-y melodramatics on occasion, but he's not wrong.)
"Words ought to be a little wild - for they are assaults of thought on the unthinking."
- John Maynard Keynes
- John Maynard Keynes
Re: If I press a key on your pc, a sound plays on yours. Hel
Welp, thanks for the replies. Too complicated for little old me. Ah well, just a thought..
I made a deviantart page.
'....The baron is a gay old rogue with an eye for the ladies....'
'....The baron is a gay old rogue with an eye for the ladies....'


