xo::MessageRelay method encode_message (public)

 <instance of xo::MessageRelay[i]> encode_message mode msg

Defined in packages/xotcl-core/tcl/message-relay-procs.tcl

Provide different "encoding" depending on the mode. Notice that for one chat, multiple clients might have difference modes, since the modes are determined at also by the capabilities of the client browser. So the incoming message has to be recoded multiple times.

Parameters:
mode (required)
msg (required)

Testcases:
No testcase defined.
Source code:
set msg [encoding convertto utf-8 $msg]
if {$mode eq "scripted"} {
  #::sec_handler_reset
  #ns_log notice "SEND data <$msg> encoded <$emsg>"
  set jsMsg [subst {
    <script nonce='[::security::csp::nonce]'>
        window.parent.postMessage($msg);
    </script>
  }]
  set msg [format %x [string length $jsMsg]]\r\n$jsMsg\r\n
} else {
  set msg [string cat {data: } $msg \n\n]
}
#ns_log notice "#### [self] encode_message <$mode> returns <$msg>"
return $msg
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: