Messaging/notifications from users to friends?

2 views
Skip to first unread message

John Panzer

unread,
Apr 4, 2008, 12:08:03 PM4/4/08
to opensocial-an...@googlegroups.com
A couple of people have asked me about an optional extension to the RESTful API to allow 1:1 messaging from a peson to one of their friends.  My response was, sure, as soon as there's such an extension defined for OpenSocial in general... I thought there had been some discussion about this in the past but I can't seem to find it.  Any pointers?

Obviously there are spam issues to deal with here, but it would be limited to existing friends and I believe various containers already support the concept, and perhaps have their own APIs for it, so this would be just a mapping of a common API to what already exists.

It would be good if the messaging system could allow for at least a clickable hyperlink (A element) within the content.  I think various restrictions should be placed on this -- trusted domains, hyperlinks  allowed only in pre-registered templates, etc. since this is clearly a phishing/malware vector.


Kevin Brown

unread,
Apr 4, 2008, 2:58:52 PM4/4/08
to opensocial-an...@googlegroups.com
This fits with the other discussion about tying up with real time communication (via XMPP). If we do support something like this we should try to ensure that these are either similar (or even the same) APIs. Real time and non real time have some slightly different semantics, so separate APIs may be appropriate, but I want to make sure that the API is consistent for gadget developers.
--
~Kevin

Cassie

unread,
Apr 6, 2008, 11:41:38 AM4/6/08
to opensocial-an...@googlegroups.com
The api already exists under opensocial.requestSendMessage:
http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.html#requestSendMessage

This call can support both real time and non real time messaging. It
allows you to specify who to send a message to (so bob could send
something to susan directly) and it also gives you the ability to send
a specific type of message. Depending on what a container supports you
can send emails, wall like stuff, notifications, or perhaps even an im
like communication.

The message object has both a body and title right now:
http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Message.Field.html

Which both allow html, but will be sanitized by the container on output.

I hope that helps.

- Cassie

Kevin Brown

unread,
Apr 6, 2008, 5:01:06 PM4/6/08
to opensocial-an...@googlegroups.com
requestSendMessage is not really appropriate for real time communication. It's suitable for one way, stateless communication (such as email), but managing a normal rt session requires establishing a two way channel between client and server, client and client, or both. You're right that it would probably cover what John's asking about, but it wouldn't really cover IM (or any other real time protocol) in a practical way. Solid real time communication support is a key piece of infrastructure that will facilitate games, collaborative document composition, IM, voice, video, and lots of things I'm probably not thinking of yet. A typical rt api might look something like this:

function onMessage(msg) {
  if (validateMove(msg)) {
    alert(msg.getUser().getDisplayName() + " moved: " + msg.getField("piece") + " to " + msg.getField("location"));
    updateBoard(msg.getField("piece"), msg.getField("location"));
  } else {
    alert("Your opponent is attempting to cheat. Terminating game...");
    channel.close();
  }
}

var channel = opensocial.openRtChannel("myFakeChessGame", onMessage);
channel.invite(person, onInviteAccepted);
...
channel.sendMessage(person, opensocial.newMessage("Check mate!", {piece: "knight1", location: "f4", checksum: lastChecksum}));
--
~Kevin

Cassie

unread,
Apr 14, 2008, 7:10:08 AM4/14/08
to opensocial-an...@googlegroups.com
I absolutely agree with what you said Kevin, real time messaging does
deserve its own thing. However, John was just asking if sending a
message to a friend was supported in the js and it is. It also does
allow simple html.

So.. John, it is on the restful spec's plate to incorporate this now :)

- Cassie

Reply all
Reply to author
Forward
0 new messages