Skip to content
jorishermans edited this page Nov 23, 2014 · 2 revisions

Profile info & client to client communication

Adding profile data on a connection, this will make it easy to send a message to a certain profile group or sending messages to an individual, without knowing his websocket id.

On the client you can set the current browser user his profile data as follow.

 var profileInfo = { 'name' : chatName};
 forceClient.initProfileInfo(profileInfo);

On the server you can send something to a profile or a profile group by the following method in sendable.

sendable.sendToProfile('name', name, 'private', message);

You can also listen to profileChanges by using the following method on the forceServer.

fs.onProfileChanged().listen((e) => print("$e"));

Now you can send directly from the client to another client, the server notice the message type and forward it directly to the corresponding client. No coding on server required todo this!

Just add the following code in your client side code.

forceClient.sendToProfile(key, value, request, data);