Web Connection
sockets
Gravatar is a globally recognized avatar based on your email address. sockets
  Jim Monte
  All
  Apr 14, 2021 @ 06:33pm

Been trying to use the socket stuff.. seems everytime I try to add a property to lomsg.. the assign method prevents it.. I need to send SDP messages to the WC server and have it broadcast to all clients.. I final realized you prevent keywords..etc to be added to objects in the assign event... Is there other ways to use these sockets that will just allow me to send an sdp message to WC server... and just broatcast that message back to all the clients? I could use ajax.. and have a REFESH on the clients HTML page.. but defeats the purpose of using WC for sockets with WebRTC...

when sending SDP message to WC.. in the __websocket() the lomsg object is correct then after calling THIS.OnWebSocket(loWebSocket) my SDP object vanishes.. Not sure why WC _websocket() can receive the SDP json turn it into a real object.. But can not turn around and just broadcast it..

Gravatar is a globally recognized avatar based on your email address. re: sockets
  Rick Strahl
  Jim Monte
  Apr 15, 2021 @ 12:45am

You can't add data to the object - well you can, but Web Connection will ignore it.

You add your data - as JSON - to the .message property. Look at the example and think of the text message as the data. Instead of sending the chat message, send your data as a JSON string (the helpers will actually handle the JSON encoding/decoding). I think the simplest way to see how this works is the FoxPro example here:

Making a Web Socket Call from Foxpro

Just replace the .message with your data:

loMsg.Message = JsonSerialize( loMyDataObject )

The idea is that you never send a raw message but rather send a message object that has basic information about the message (ie. recipients and actions) which are very common for most broadcast applications.

As mentioned in the docs - Web Connection doesn't provide a raw socket server because there's no clean way to handle the routing in that scenario. What this means is that both client and server code needs to wrap the actual data you are sending into the message property of that object. That's what the helper methods are there for in the JavaScript and FoxPro helpers - they'll help you create the message and attach the data with a single command.

The reason for all of this is that without it you can do very simple things but it gets complicated quickly if you need to broadcast messages to specific groups of people but not all. That's the reason there's the wrapper that lets you specify who to send to and to separate multiple 'actions' that can differentiate many different operations. Without that you have to manage that all yourself for every scenario.

The docs show examples of how to broadcast and capture in JavaScript and FoxPro. Just keep in mind that the .message is a string data object that contains your message data payload.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: sockets
  Jim Monte
  Rick Strahl
  Apr 15, 2021 @ 08:10am

ok.. I wrapped the SDP json inside the object.message... then strip out and/or parse what I need from the message prop.... So basically what I have are SDP json-objects inside of WCs message. I broadcast this back to clients.. and just needed intercept the massage prop and turn it to the SDP object Works just fine!!!

Thanks Rick!

Gravatar is a globally recognized avatar based on your email address. re: sockets
  Rick Strahl
  Jim Monte
  Apr 15, 2021 @ 02:06pm

Yup... looks like you figured it out.

The docs being out of date probably didn't help... they are updated now.

+++ Rick ---

© 1996-2021