How can I send plain text data/ JSON data instead of binary (opcode2) in secure websocket message of opentok - opentok

I have a query, Is it possible to send plane text data instead of binary (opcode 2) in https://opentokdemo.tokbox.com.
I am trying to understand the call flow of opentokdemo.tokbox.com , I am not able to read the websocket frame as it is in binary format. I tried with fiddler and wireshark as well but not decode properly .
Now I think if I make it possible, somehow i send the plain data over secure websocket by changing in opentok.js file.
IS there a way to do like this please suggest me any idea.
Thank you

Adam here from TokBox. There is no way that I know of to do that. The binary protocol is expected on the other end so even if you didn't send binary the other side would fail.
Perhaps I can help you though with what you're trying to do? Why are you trying to read the websocket messages?

Related

How can I get access to packet CMSG fields from Golang?

I'm working on a Go program that receives packets and wants to see receipt timestamps.
In C this would be done by setting the SO_TIMESTAMP/SO_TIMETAMPNS socket option and then using the CMSG macros to extract data from a control message buffer structure,
I have searched the Go documentation for a way to do this, in vain. Can anyone point me art a working example?
You can get them from UDPConn::ReadMsgUDP, the ancillary data was named "oob" for some weird reason, but it is the ancillary channel with the control messages.
You can parse the []byte with the control message data using x/sys/unix::Cmsghdr (https://pkg.go.dev/golang.org/x/sys/unix#Cmsghdr)
There should be a better way, but at least this is not behind "internal"...

How to send and read binary data in TinyXML?

I need to send file data (picture,text, word,excel etc) in xml. I need to send file data as binary data. I read some article about this but couldnt get how to achieve in TinyXml. Please read below post:
http://www.techrepublic.com/article/send-binary-data-in-xml/1050529
Above post has mentioned three approaches. Now let me know what approach is possible in tinyXML. If possible send me some sample code to send and read binary data in tinyXML. I searched a lot but couldnt get any way of doing this.
If sample code is not possible then please list down API I need to use so I will try that and update here my status.

QUdpsocket send and receive an image

I want to grab the PC screen. I use QPixmap::grab, and I get a QPixmap. Then I want to send this image using QUdpsocket. The image has been already converted to binary.
http://www.java2s.com/Code/Cpp/Qt/Udpserver.htm 's demo can send and receive the image, but use pixel, I wanna send all binary data each 250ms.
If you want to send the whole image in one go, you could try using QDataStream for serialization of a QByteArray.
The problem with this is that a UDP packet has a limited size, and could get fragmented if too large, and while large packets may work on your LAN, they could get fragmented over the internet. As UDP doesn't provide ordering guarantees like TCP, the fragments could come in the wrong order without the QDataStream header. This is probably why in your linked example they are only sending a single line at a time.
You may want to read a comparison of TCP and UDP and evaluate which fits your needs better.

What data formats can AJAX transfer?

I'm new to AJAX, but as an overview I'd like to know what formats you can upload and download. Is it limited to JSON or XML or can you even send binary types like MP3 or UTF-8 HTML. And finally, do you have full control over the data, byte for byte in something like a byte array, or is only a string sent/received.
If we are talking about ajax we are talking about javascript? And about XMLHTTPRequest?
The XMLHttpRequest which is only a http request can transfer everything. But there is no byte array in javascript. Only strings, numbers and such. Every thing you get from an ajax call is a piece of text (responseText). That might be parsed into XML (which gives you reponseXML). Special encodings should be more a matter of the http transport.
The binary stuff is not ajax dependent but javascript dependent. There are some weird encodings for strings to deliver byte data inside in javascript (especially for images) but it is not a general solution.
HTML is not a problem and that is the most prominent use case. From this type of request you get an HTML string delivered and that is added to some node in the DOM per innerHTML that parses the HTML.
Since data is transported via HTTP you will have to make sure that you use some kind of encoding. One of the most popular is base64 encoding. You can find more information at: http://www.webtoolkit.info/javascript-base64.html
The methodology is to base64-encode the data you would like to send and then base64-decode the data at the server(or the client) and use the original data as you intended.
You can transfer any type of data either string or bytes
You can send anything you like, the problem may be how to handle it once you get it ;)
Standard HTML is probably the most common type of ajax content in use out there - you can choose character encoding too, although it's always best to stick with one type of encoding.
AJAX simply means you're transferring data asynchronously over HTTP with a JavaScript call. So your script makes a "normal" HTTP request using the XmlHttpRequest() object. However, as the name implies, it's really only suited for text-based data formats since you generally want to perform some action on the client side with the data you got back from the server (not always though, sometimes people just send XmlHttpRequests only to update something on the server).
On a side note, I have never seen an application where sending binary data would have been appropriate anyway.
Most often, people choose to send data over to the server with POST or GET (which is basically a method to transfer name-value pairs inherent to HTTP). For sending more complex data, for example hierarchical structures, they need to be encoded somehow. XML documents can be made natively per JavaScript, sent over to the server and get parsed into whatever data types necessary. But since XML can be a bit of a pain, many devs use JSON encoded data instead because it's easy to generate and easy to parse.
What the server sends back is equally as arbitrary. Usually, you specify a callback function in your Javascript that handles the incoming data. Again, the popular choices are XML and JSON, they parse easily into a document object or an array structure respectively. You could also send plain text or some other packaging but remember that you then have to take care of extracting the usable data from it yourself. Sometimes, it can also be beneficial to send actual HTML fragments to the client to update something on the page directly.
For starters, I suggest you have a look at JQuery. It's a very lightweight framework that abstracts many of evil compatibility stuff and lets you write AJAX requests very nicely.
You can move anything that can be sent over HTTP. There are restrictions about the call being made to the same domain as the page loaded from, but not on the content of the transfer. You can do either GET or POST transactions too.
There is a Digg the Blog entry titled DUI.Stream and MXHR that shows off what they call "Multipart XMLHttpRequests." It is alpha code now, but there is a demo that handles images.

Buffered Multipart Form Posts in Ruby

I am currently using Net::HTTP in a Ruby script to post files to a website via a multipart form post. It works great for small files, but I frequently have to send very large files using this script, and HTTP#post only seems to accept post data as a String object, which means that the file I'm sending has to be read into memory before anything can be sent. This script is running on a busy production server, so it's unacceptable to gobble up hundreds of megabytes of RAM just to send a file.
Ideally, there'd be a method that could be given a buffer size and an IO object, and would send off buffer-sized chunks of data, reading from the IO object only as required. What would be the best way to make this happen? Did I miss something relevant in Net::HTTP?
Update: Net::HTTP#body_stream(input) looks good, though the documentation is rather... sparse. Anyone able to point me to a good example of this in action?
Actually I managed to upload a file using body_stream. The full source code is here:
http://stanislavvitvitskiy.blogspot.com/2008/12/multipart-post-in-ruby.html
Use Net::HTTP#body_stream(input)
Example for multipart post without streaming:

Resources