Results 61 to 90 of 97
-
-
03-17-2018
Javascript is easy, a lot of people are confused between java and javascript what they think it's the same but it's not true.
btw, maks would you mind to use node.js to solve your problem with udp?
anyway:
Code:var udp = require('udp-request') var socket = udp() socket.on('request', function (request, peer) { console.log('request:', request.toString()) socket.response('echo: ' + request.toString(), peer) }) socket.listen(10000, function () { socket.request('hello', {port: 10000, host: '127.0.0.1'}, function (err, response) { console.log('response', response.toString()) socket.destroy() }) })
before to execute this, you need to do npm install, I don't know about UDP, what do you really except?
-
03-17-2018
the code you posted is the thing I was successfully able to do in 3 different languages.
I want a background service that sends a broadcast *when I receive a phone call*. As far as I know I can only do that in java or xamerin.
-
03-17-2018
The same thing you wrote, in VB
Code:Sub Main() 'Console.WriteLine("Receiver") Do Dim UDPClient As UdpClient = New UdpClient() UDPClient.Client.SetSocketOption(SocketOptionLevel.Socket, _ SocketOptionName.ReuseAddress, True) UDPClient.Client.Bind(New IPEndPoint(IPAddress.Any, 44126)) Try Dim iepRemoteEndPoint As IPEndPoint = New _ IPEndPoint(IPAddress.Any, 44126) Dim strMessage As String = String.Empty Do Dim bytRecieved As Byte() = _ UDPClient.Receive(iepRemoteEndPoint) strMessage = Encoding.ASCII.GetString(bytRecieved) Console.WriteLine("This is the message you received: " + strMessage) My.Computer.Audio.Play("C:\Users\overwatch\Downloads\mario coin.wav", AudioPlayMode.WaitToComplete) Loop While (strMessage <> "exit") UDPClient.Close() Catch e As Exception Console.WriteLine(e.ToString()) End Try Loop
Code:import os while 1: from socket import * s=socket(AF_INET, SOCK_DGRAM) s.bind(('',44126)) m=s.recvfrom(1024) print m[0] #Uncomment for Mac version os.system("afplay ./ring.wav") #Uncomment for Windows #os.system("start .\ring.wav")
-
03-17-2018Code:
var PORT = 44126; var HOST = '127.1.1.1'; var client = dgram.createSocket('udp4'); var play = require('play'); client.on('listening', function () { var address = client.address(); console.log('UDP Server listening on ' + address.address + ":" + address.port); }); client.on('message', function (message, remote) { console.log(remote.address + ':' + remote.port +' - ' + message); play.sound('./sound-files/ring.wav'); }); //calling client.send(message, 0, message.length, PORT, HOST, function(err, bytes) { if (err) throw err; console.log('UDP message sent to ' + HOST +':'+ PORT); });
-
03-17-2018
I simulated it, it looks like it's working.
Left window is which it calls eg. sending a broadcast, basically a function which is related to client.send to what's address and some stuff.
Right window is *when I receive a phone call* it outputs a log with some address info, it can do whatever like playing sound.
-
03-17-2018
that's great now I have the same thing I already wrote in 5 languages
-
-
03-17-2018
-
03-17-2018Code:
public void myRealMethod(View view) { String messageStr = "Fuck java"; int server_port = 44126; try { DatagramSocket s = new DatagramSocket(); InetAddress local = InetAddress.getByName("192.168.255.255"); int msg_length = messageStr.length(); byte[] message = messageStr.getBytes(); DatagramPacket p = new DatagramPacket(message, msg_length, local, server_port); s.send(p); } catch (Exception e) { }
-
03-17-2018
I'm p sure that one works but I can't figure out how to fucking call a fucking method that doesn't fucking return anything
-
-
03-17-2018
elzzz are u still a virgin? plz don't become a furry, qt mestiza hookers are so cheap in your country
-
-
-
03-17-2018
powershell, 7 languages
Code:$port=44123 $endpoint = new-object System.Net.IPEndPoint ([IPAddress]::Any,$port) $udpclient=new-Object System.Net.Sockets.UdpClient $port $content=$udpclient.Receive([ref]$endpoint) [Text.Encoding]::ASCII.GetString($content) write-host $content
-
03-17-2018
The client version can do REST to backend server in real time which is background service that client is listening everytime, then call a sound file, the backend server is the alarm that sends udp packet to notify every devices when the phone rings.
That's another possible design.
-
03-17-2018
if I can't figure out how to read the phone state I can't do a goddamn thing
-
03-17-2018
You need to use this service https://www.twilio.com to get phone state, also it's used to make outbound calls
-
-
03-17-2018
why do I need a voip api to use functionality that's built into android
-
03-17-2018
this is what I need I just don't know enough about the structure of an android project to get the fucking thing working
https://developer.android.com/refere...eListener.html
-
-
03-18-2018
Yeah, API levels and Permissions belong the Android systems are pain in the ass, even Java is outdated and shitty syntax to read like @Override and class with inside of function.
However, NativeScript is fucking awesome, basically if you port Java shitty code to Javascript which is very easy to do UI.
https://www.nativescript.org
You showed me PhoneStateListener, I make an example as incoming call like this:
Code:private class CallStateListener extends PhoneStateListener { @Override public void onCallStateChanged(int state, String incomingNumber) { } } tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); tm.listen(callStateListener, PhoneStateListener.LISTEN_CALL_STATE);
Code:var callStateListener = android.telephony.PhoneStateListener.extend({ onCallStateChanged: function (state, incomingNumber) { } var application = require("application"); var tm = application.android.context.getSystemService(android.content.Context.TELEPHONY_SERVICE); tm.listen(new callStateListener(), android.telephony.PhoneStateListener.LISTEN_CALL_STATE);
-
03-18-2018
frankly I'd too irritated with the whole thing to spend any more time on it, but I'll give that a shot I think it's more or less the same thing dp recommended
-
03-18-2018
So good
Thanks g
Uys[COOL LIST] Battery Bits, Lily, Knights Templar, snoofalew, poopalew [/COOL LIST]
*****Official Rubynet Welcoming Committee Leader*****
-
03-18-2018
I got it working, sort of. I successfully spawned a background service, it detects incoming calls and sends a packet like it should. however
on the emulator, I need to specify an address, a broadcast address won't work. probably because the emulator thinks it's on cellular and you can't broadcast on a wan
on the actual phone, it only works if the app is in the foreground, the service doesn't seem to be listening after I hit the home button.
-
-
03-18-2018
What good is a background server going to do if the notifier application on the phone doesn't work
-
03-18-2018
I need to figure out how services work in more depth
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)