Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bluetooth Chat application

 
Abhi Venu
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is continuation of my earlier post http://www.coderanch.com/t/454340/Java-Micro-Edition/Mobile/Bluetooth-Chat-application
I would like to know is there anyway by which a messge can be send to the sender when a message is recieved, i meant identifying sender's connection URL from receieved connection i want a url like this "btspp://localhost:" + SERVICE_ID.toString() + ";name=ChattingService;authorize=false";
 
Ashley Burton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I've just started my adventure with jsr-82 so this sollution may not be the best.
StreamConnection is just an interface with a few important methods like openInputStream, openOutputStream etc.
You can try to identify the class implementing this intefrace and find out if it exposes any methods that suit you requirements eg connection endpoints.


Other sollution:
Sending message thread can open input stream(using the same StreamConnection) and read the notfication from message receiver.
Of course message receiver must send the notification by write the output stream(created from the same StreamConnection).




Hope this will help somehow.

Ash
 
Abhi Venu
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

yahooooooooo...................
My problem is solved. I used a method to solve it.
While sending message ,senders conncetion URL was appended to the message to be sent ..that is it can be considered as a header appended to the message to be send .
On the receiving end i stripped the message to get the senders address.

It is done as follows

After registering service in the SDDB ie following code is used to get connection URL to this particular service ,which is then assigned to a string sender

// For storing Senders Address in a variable and appending it while sending messages.
ServiceRecord rb= LocalDevice.getLocalDevice().getRecord(myNotifier);
// gets senders connection URL
sender=rb.getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT,false).toString();


This is appended with message to be sent delimited by a caharacter. ~
argument passed to message sending thread
new SendMessage(sender+"~"+tosend.getString(),currentrecipenturl)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic