ricohapi / theta-client

A library to control RICOH THETA
MIT License
18 stars 13 forks source link

fake-theta compatibility #23

Closed codetricity closed 1 year ago

codetricity commented 1 year ago

Does theta-client work with fake-theta?

I'm using this endpoint in a Flutter app.

  final endpoint = 'https://fake-theta.vercel.app';

I am accessing listFiles like this:

 var imageList =
            await _thetaClient.listFiles(FileTypeEnum.image, 2);

I am getting this error:

E/flutter (32599): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(NotConnectedException, java.lang.NullPointerException, null, null)
E/flutter (32599):

This is the output.

I/flutter (32599): call listFiles
I/System.out(32599): HttpClient: REQUEST: https://fake-theta.vercel.app/osc/commands/execute
I/System.out(32599): METHOD: HttpMethod(value=POST)
I/System.out(32599): COMMON HEADERS
I/System.out(32599): -> Accept: application/json
I/System.out(32599): -> Accept-Charset: UTF-8
I/System.out(32599): -> Cache-Control: no-cache
I/System.out(32599): CONTENT HEADERS
I/System.out(32599): -> Content-Length: 126
I/System.out(32599): -> Content-Type: application/json; charset=utf-8
I/System.out(32599): BODY Content-Type: application/json; charset=utf-8
I/System.out(32599): BODY START
I/System.out(32599): {"name":"camera.listFiles","parameters":{"fileType":"image","startPosition":0,"entryCount":2,"maxThumbSize":0,"_detail":true}}
I/System.out(32599): BODY END
D/TrafficStats(32599): tagSocket(125) with statsTag=0xffffffff, statsUid=-1
I/System.out(32599): HttpClient: RESPONSE: 200 OK
I/System.out(32599): METHOD: HttpMethod(value=POST)
I/System.out(32599): FROM: https://fake-theta.vercel.app/osc/commands/execute
I/System.out(32599): COMMON HEADERS
I/System.out(32599): -> Cache-Control: public, max-age=0, must-revalidate
I/System.out(32599): -> Connection: keep-alive
I/System.out(32599): -> Content-Length: 474
I/System.out(32599): -> Content-Type: application/json; charset=utf-8
I/System.out(32599): -> Date: Fri, 28 Apr 2023 13:24:56 GMT
I/System.out(32599): -> Etag: W/"1da-hHC5yGdk33EyyPKk7kdMEU5xSy8"
I/System.out(32599): -> Server: Vercel
I/System.out(32599): -> Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
I/System.out(32599): -> X-Vercel-Cache: MISS
I/System.out(32599): -> X-Vercel-Id: sfo1::iad1::lhxgq-1682688296310-f744396b0ed8
I/System.out(32599): BODY Content-Type: application/json; charset=utf-8
I/System.out(32599): BODY START
I/System.out(32599): {"results":{"entries":[{"dateTime":"2015:07:10 11:05:18","_favorite":false,"fileUrl":"https://fake-theta.vercel.app/files/100RICOH/R0010001.JPG","isProcessed":true,"name":"R0010001.JPG","previewUrl":"","size":4051440},{"dateTime":"2015:07:10 11:05:18","_favorite":false,"fileUrl":"https://fake-theta.vercel.app/files/100RICOH/R0010002.JPG","isProcessed":true,"name":"R0010002.JPG","previewUrl":"","size":4051440}],"totalEntries":10},"name":"camera.listFiles","state":"done"}
I/System.out(32599): BODY END
E/flutter (32599): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(NotConnectedException, java.lang.NullPointerException, null, null)
E/flutter (32599):

In addition to the error, I cannot access the ThetaFiles.fileList and ThetaFiles.totalEntries properties.

How can I use theta-client with fake-theta for the basic APIs supported by fake-theta?

The same listFiles command works with a normal http.post command in my Flutter app. At the moment, I am forced to build the app with the http package instead of theta-client. However, I would like to use theta-client.

ywatanabe-dev commented 1 year ago

Thank you for your comment. We are sorry for the delay in replying as we were on vacation.

Theta-client does not currently support https connection, so it will not be able to connect to the fake-theta endpoint. We are currently investigating how to fix this.

Best regards,

ywatanabe-dev commented 1 year ago

@codetricity With the update of Fake-THETA, the listFiles command of theta-client on Android now works. The reason for the error was that theta-client calls the listFiles command with the _detail option, while Fake-THETA did not support this option.  Since v0.3.0, Fake-THETA supports the _detail option, and this problem is resolved.

(On iOS, the connection between theta-client and Fake-THETA is still not possible, probably due to problems with the http client CIO on iOS native environment.)

codetricity commented 1 year ago

This is great news. Thanks for all your work.