iink SDK Web

Answered

How to get recognition results by websocket?

I have connected to the server and disabled hmac. 

After sending the server "newContentPackage", "newContentPart" amd "addStroktes", how can I get the recognition results of thoses strokes?




Best Answer

Dear Xinchao Gou.


Thank you for contacting us.

With Websocket, the recognition result are sent asynchronously by the server in the"exported" message

Thus in your client application you can retrieve the recognition result by analyzing the content of the exported message.

The recognition result is contained into the "exports" field with one line per exported format.


For instance, when writing 1 in a Math part, the exported message would look like:


{"type":"exported","partId":"nmkxlzym","exports":{"application/x-latex":"1","application/mathml+xml":"<math xmlns='http://www.w3.org/1998/Math/MathML'>\n <mn> 1 </mn>\n</math>\n"}}


Best regards,


Gwenaëlle


Answer

Dear Xinchao Gou.


Thank you for contacting us.

With Websocket, the recognition result are sent asynchronously by the server in the"exported" message

Thus in your client application you can retrieve the recognition result by analyzing the content of the exported message.

The recognition result is contained into the "exports" field with one line per exported format.


For instance, when writing 1 in a Math part, the exported message would look like:


{"type":"exported","partId":"nmkxlzym","exports":{"application/x-latex":"1","application/mathml+xml":"<math xmlns='http://www.w3.org/1998/Math/MathML'>\n <mn> 1 </mn>\n</math>\n"}}


Best regards,


Gwenaëlle

Dear Gwenaëlle

Thank you for your reply.  Do I need to send "export" message to the serve when I want to recognise the "part" I created?

for example like this one: 

msg_export = {
            "type": "export",
            "partId": partId,
            "mimeTypes": ["application/x-latex"]
        }

 If I understand it correctly, then I'm supposed to get the "exported" message from the serve. But I don't get anything actually. 

What could be the possible problem? 

Best regards,

Xinchao

Dear Xinchao Gou,


currently, in order to export, you can refer to our websocket sample with "on-demand" export:

-https://myscript.github.io/MyScriptJS/examples/non-version-specific/on_demand_exports.html

-https://github.com/MyScript/MyScriptJS/blob/master/examples/non-version-specific/on_demand_exports.html


If you are not able to have any result, we invite you to check your console to see if you have any error message.


Best regards,


Olivier

Dear Olivier

Thanks a lot for your help. The link helped a lot. I solved my problems.

Best regards,

Xinchao

Dear Xinchao Gou,


thank you for the update, I am glad we were of help.


Feel free to contact us if you have any question.


Best regards,


Olivier