triniwiz / nativescript-socketio

Socket.IO for nativescript
Apache License 2.0
71 stars 31 forks source link

Error specifying cookies on Android #92

Closed ajaymaru closed 5 years ago

ajaymaru commented 5 years ago

Make sure to check the demo app(s) for sample usage

Done.

Make sure to check the existing issues in this repository

This relates to issue #91. Once that issue is fixed, I get a runtime error "System.err: Error: Cannot convert array to Ljava/lang/Object;"

If the demo apps cannot help and there is no issue for your problem, tell us about it

Please, ensure your title is less than 63 characters long and starts with a capital letter.

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

Describe the steps to reproduce it. When trying to set cookies in app.module.ts, runtime error thrown. See stack trace below: SocketIOModule.forRoot(<url_value>, { debug: true, cookie: ["<name>=<value>; Domain=<domain_value>; Path=/; Expires=<expiration_time>"], forceNew: true, forceWebsockets: true, secure: true })

System.err: An uncaught Exception occurred on "main" thread. System.err: Calling js method call failed System.err: Error: Cannot convert array to Ljava/lang/Object; at index 0 System.err: StackTrace: System.err: Frame: function:'call', file:'file:///node_modules/nativescript-socketio/socketio.js:75:0 System.err: at com.tns.Runtime.callJSMethodNative(Native Method) System.err: at com.tns.Runtime.access$2300(Runtime.java:34) System.err: at com.tns.Runtime$3.run(Runtime.java:1263) System.err: at android.os.Handler.handleCallback(Handler.java:739) System.err: at android.os.Handler.dispatchMessage(Handler.java:95) System.err: at android.os.Looper.loop(Looper.java:145) System.err: at android.app.ActivityThread.main(ActivityThread.java:6134) System.err: at java.lang.reflect.Method.invoke(Native Method) System.err: at java.lang.reflect.Method.invoke(Method.java:372) System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

Is there any code involved?

See above.

The issue is that const list = new java.util.ArrayList(); list.add(cookies); is unable to convert the JS array to the Java ArrayList.

Needs to change to something like: const list = new java.util.ArrayList(java.util.Arrays.asList(cookies));

Easy fix. Sending a PR.

ajaymaru commented 5 years ago

PR #93 submitted