wiki:WikiStart/OngoingWork/WebService

Version 4 (modified by sylvain.joyeux, 5 years ago) (diff)

--

Protocol

  • marshalling formats
    • JSON
    • BSON
    • google protobufs
  • two modes of operatoins
    • request based
    • stream-based (mostly useful for reading ports to avoid the overhead of repeating requests, could be generalized to any orocos/async events)
  • custom protocol or http (REST) ?
    • REST protocol has good library support both client and server side
      • very well suited for browser-based interaction (because it is a very common pattern)
      • can easily be upgraded to a rich server (i.e. having things rendered server-side)
    • Sockets don't need a webserver running
      • Sylvain IMO a non-issue, Ruby libraries as e.g. Rack have very good support to start thin webservers "out of the box"
      • websocket protocol implemented in browser
      • socket don't need a websocket library

requests

  • Sylvain IMO most requests that can be made on the orocos.rb API:
    • nameservice browsing
    • task states
    • full model
    • port reading/writing
    • property reading/writing

Ruby

  • gem Yail-ruby promising JSON parser
    • Sylvain having done a bit of research, the best JSON support out there is given by multijson - simply uses the best JSON library available on the system. If we write a generic type-to-hash support in typelib, we can use any JSON marshaller.
    • sending via socket, websocket possible tand tested (only JSON decode on socket untested)
      • Sylvain that is independent of the JSON library used ...
    • parser can handle nested types (Sylvain what would it be used for ?)
    • needs a serializer function for types which creates (nestes) hashes
      • this can be implemented directly in typlib-ruby as generalized method using field iterators
      • example:
        class Types::Base::Vector3d
          def to_json(*a)
            {
              'json_class'   => self.class.name,
              'data'         => [ :x => x(), :y => y(), :z => z() ]
            }.to_json(*a)
          end
        end
        
        class Types::Base::Samples::RigidBodyState
          def to_json(*a)
            {
              'json_class'   => self.class.name,
              'data'         => [ 
                                  :time => time, 
                                  :sourceFrame => sourceFrame, 
                                  :targetFrame => targetFrame, 
                                  :position => position,
                                  #:cov_position => cov_position,
                                  :orientation => orientation,
                                  :velocity => velocity,
                                  :angular_velocity => angular_velocity
                                  ]
            }.to_json(*a)
          end
        end
        

Browser

  • websocket preferred (I would think "REST - i.e. HTTP - preferred" Sylvain)
  • JSON parser integrated (no external .js lib)
  • jQuery UI looks like a nice UI lib

generic interface

  • socket, but no UI tools