iink SDK Web

Answered

Not receiving JIIX with strokes with WebSockets

Hi there,


I am trying export JIIX along with the strokes using the Websocket protocol on. I was following the advice I found here, which looks like this in my configuration:


  

editorElement = iink.register(editorDivRef.current, {
      recognitionParams: {
        type: "TEXT",
        protocol: "WEBSOCKET",
        server: {
          scheme: "https",
          host: "cloud.myscript.com",
          applicationKey: applicationKey,
          hmacKey: hmacKey,
          websocket: {
            pingEnabled: false,
            autoReconnect: true,
          },
          iink: {
            export: {
              jiix: {
                strokes: "true",
              },
            },
          },
        },
      },
    });

 

 I get the JIIX but without strokes. Here's my sample handwriting:

image


How to log:


  

    editorDivRef.current.addEventListener("exported", (event) => {
      const exports = event.detail.exports;
      if (exports) {
        console.log(JSON.stringify(exports));
      }
    });

 And the output:


  

{"application/vnd.myscript.jiix":"{\n \"type\": \"Text\",\n \"label\": \"new one\\nnow two\",\n \"words\": [ {\n   \"label\": \"new\",\n   \"candidates\": [ \"new\", \"hew\", \"how\", \"hw\", \"Hew\" ]\n  }, {\n   \"label\": \" \"\n  }, {\n   \"label\": \"one\",\n   \"candidates\": [ \"one\", \"One\", \"onc\", \"onee\", \"ane\" ]\n  }, {\n   \"label\": \"\\n\",\n   \"reflow-label\": \" \"\n  }, {\n   \"label\": \"now\",\n   \"candidates\": [ \"now\", \"nar\", \"hew\", \"har\", \"new\" ]\n  }, {\n   \"label\": \" \"\n  }, {\n   \"label\": \"two\",\n   \"candidates\": [ \"two\", \"tho\", \"Two\", \"thro\" ]\n  } ],\n \"version\": \"3\",\n \"id\": \"MainBlock\"\n}","text/plain":"new one\nnow two"}

 

 What do I need to change in order to get the strokes like Gwenaelle's example in here? As far as I can see my configuration matches hers.

 


Best Answer

Hi!


Thank you for contacting us.


I am quite puzzled by you exported result as your configuration seems indeed OK.


To confirm whether this is a configuration issue or another integration issue, you might do the same test as I did: 

I have installed locally the iinkJS and modified the "Configure on-demand export" example to export the strokes.


Here the procedure:


git clone  https://github.com/MyScript/iinkJS.git

cd iinkJS

npm i

npm run dev


Then edit the iinkJS\examples\non-version-specific\on_demand_exports.html file


modify its configuration block to add the export jjix stroke and with your keys:


      iink.register(editorElement, {

        triggers: {

          exportContent: 'DEMAND'

        },

        recognitionParams: {

          server: {

            scheme: 'https',

            host: 'webdemoapi.myscript.com',

            applicationKey: 'xxx',

            hmacKey: 'yyy',

            websocket: {

              pingEnabled: false,

              autoReconnect: true

            }

          },

          iink: {

            export: {

              jiix: {

                strokes: "true",

              },

            },

          },

        },

      });



Then open the example in a browser: http://localhost:8080/examples/non-version-specific/on_demand_exports.html


Write some strokes click on the export button, you should see the strokes information, as in the attached image.



Could you please, perform the test and confirm whether you have the stroke information?



Best regards,


Gwenaëlle


Answer

Hi!


Thank you for contacting us.


I am quite puzzled by you exported result as your configuration seems indeed OK.


To confirm whether this is a configuration issue or another integration issue, you might do the same test as I did: 

I have installed locally the iinkJS and modified the "Configure on-demand export" example to export the strokes.


Here the procedure:


git clone  https://github.com/MyScript/iinkJS.git

cd iinkJS

npm i

npm run dev


Then edit the iinkJS\examples\non-version-specific\on_demand_exports.html file


modify its configuration block to add the export jjix stroke and with your keys:


      iink.register(editorElement, {

        triggers: {

          exportContent: 'DEMAND'

        },

        recognitionParams: {

          server: {

            scheme: 'https',

            host: 'webdemoapi.myscript.com',

            applicationKey: 'xxx',

            hmacKey: 'yyy',

            websocket: {

              pingEnabled: false,

              autoReconnect: true

            }

          },

          iink: {

            export: {

              jiix: {

                strokes: "true",

              },

            },

          },

        },

      });



Then open the example in a browser: http://localhost:8080/examples/non-version-specific/on_demand_exports.html


Write some strokes click on the export button, you should see the strokes information, as in the attached image.



Could you please, perform the test and confirm whether you have the stroke information?



Best regards,


Gwenaëlle

Hi Gwenaëlle,


thanks for your help! With the working example I was able to spot the error: I had set recognitionParams.server.iink.export.jiix.strokes = true in the configuration but I needs to be recognitionParams.iink.export.jiix.strokes = true on the same level as server and not as it's child. This is the correct way:

 

editorElement = iink.register(editorDivRef.current, {
      recognitionParams: {
        type: "TEXT",
        protocol: "WEBSOCKET",
        server: {
          scheme: "https",
          host: "cloud.myscript.com",
          applicationKey: applicationKey,
          hmacKey: hmacKey,
          websocket: {
            pingEnabled: false,
            autoReconnect: true,
          },
        },
        iink: {
          export: {
            jiix: {
              strokes: "true",
            },
          },
        },
      },
    });

 

Hi!


Thank you for your update!

 I am glad that you've fixed your issue and get the strokes in the JIIX export.


Regards,


Gwenaëlle