ICEmobile
  1. ICEmobile
  2. MOBI-916

Support ICEpush within BridgeIt JavaScript API

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: EE 1.3
    • Fix Version/s: BridgeIt 1.0
    • Component/s: Core
    • Labels:
      None
    • Environment:
      ICEpush, BridgeIt

      Description

      A simplified BridgeIt API should allow JavaScript developers to use ICEpush as a service.

        Activity

        Hide
        Ted Goddard added a comment -

        Currently two configuration lines are necessary to initiate ICEpush as a service

        <script type="text/javascript" src="http://labs.icesoft.com/push/code.icepush"></script>

        <script type="text/javascript">
        ice.push.configuration.contextPath = "http://labs.icesoft.com/push/";
        </script>

        This can be reduced to a single bridgeit configuration of "http://labs.icesoft.com/push/".

        Show
        Ted Goddard added a comment - Currently two configuration lines are necessary to initiate ICEpush as a service <script type="text/javascript" src="http://labs.icesoft.com/push/code.icepush"></script> <script type="text/javascript"> ice.push.configuration.contextPath = "http://labs.icesoft.com/push/"; </script> This can be reduced to a single bridgeit configuration of "http://labs.icesoft.com/push/".
        Hide
        Ted Goddard added a comment -

        bridgeit.usePushService("http://labs.icesoft.com/push/", apiKey)

        Show
        Ted Goddard added a comment - bridgeit.usePushService("http://labs.icesoft.com/push/", apiKey)
        Hide
        Ted Goddard added a comment -

        The essential features from ICEpush are covered by: createPushId, addGroupMember, register, resumeConnection*, pauseConnection*. not called by application, will be integrated with bridgeit.js or code.icepush.

        Show
        Ted Goddard added a comment - The essential features from ICEpush are covered by: createPushId, addGroupMember, register, resumeConnection*, pauseConnection*. not called by application, will be integrated with bridgeit.js or code.icepush.
        Hide
        Ted Goddard added a comment -

        To be added to bridgeit.js in http://server.ice:8888/svn/ossrepo/icemobile/branches/icemobile-bridgeit-transition/icemobile/bridgeit/src/main/javascript/bridgeit.js

        bridgeit.usePushService(serviceURL, apiKey)

        { //load code.icepush and configure ice.push.contextPath }

        bridgeit.addPushListener(groupName, callback)

        { //test for ICEpush var pushId = ice.push.createPushId(); ice.push.addGroupMember(groupName, pushId) ice.push.register([pushId], callback); }

        bridgeit.push(groupName, options)

        { //extract delay from options or merge in ICEpush API ice.push.notify(groupName, options); }

        Implementation must have a friendly warning in the console if invoked without ICEpush being loaded via usePushService():

        "BridgeIt push cannot be used without a push service. Please set one up with bridgeit.usePushService(serviceURL, apiKey)"

        Show
        Ted Goddard added a comment - To be added to bridgeit.js in http://server.ice:8888/svn/ossrepo/icemobile/branches/icemobile-bridgeit-transition/icemobile/bridgeit/src/main/javascript/bridgeit.js bridgeit.usePushService(serviceURL, apiKey) { //load code.icepush and configure ice.push.contextPath } bridgeit.addPushListener(groupName, callback) { //test for ICEpush var pushId = ice.push.createPushId(); ice.push.addGroupMember(groupName, pushId) ice.push.register([pushId], callback); } bridgeit.push(groupName, options) { //extract delay from options or merge in ICEpush API ice.push.notify(groupName, options); } Implementation must have a friendly warning in the console if invoked without ICEpush being loaded via usePushService(): "BridgeIt push cannot be used without a push service. Please set one up with bridgeit.usePushService(serviceURL, apiKey)"
        Hide
        Ted Goddard added a comment -

        Typical application use will be:

        Perhaps in the head, but potentially elsewhere on the page:

        <script>
        bridgeit.usePushService("http://labs.icesoft.com/push/", "deadbeef")
        </script>

        In the output portion of the application:
        <script>
        bridgeit.addPushListener("chat", handleChat);
        </script>

        On an input control

        <button onclick='bridgeit.push("chat");'>Send Chat</button>

        Show
        Ted Goddard added a comment - Typical application use will be: Perhaps in the head, but potentially elsewhere on the page: <script> bridgeit.usePushService("http://labs.icesoft.com/push/", "deadbeef") </script> In the output portion of the application: <script> bridgeit.addPushListener("chat", handleChat); </script> On an input control <button onclick='bridgeit.push("chat");'>Send Chat</button>
        Hide
        Ken Fyten added a comment -
        bridgeit.usePushService(serviceURL, apiKey) {
           //load code.icepush and configure ice.push.contextPath
        }
        
        http://bridgeit.mobi/push
        
        Show
        Ken Fyten added a comment - bridgeit.usePushService(serviceURL, apiKey) { //load code.icepush and configure ice.push.contextPath } http: //bridgeit.mobi/push
        Hide
        Mircea Toma added a comment -

        Modified ICEpush to publish startConnection method so that dynamic setups can start the blocking connection without relying on document load. The method can be accessed at ice.push.connection.startConnection.

        Show
        Mircea Toma added a comment - Modified ICEpush to publish startConnection method so that dynamic setups can start the blocking connection without relying on document load. The method can be accessed at ice.push.connection.startConnection .
        Hide
        Mircea Toma added a comment -

        Implemented usePushService, addPushListener and push functions. Also tested their functionality successfully.

        Show
        Mircea Toma added a comment - Implemented usePushService , addPushListener and push functions. Also tested their functionality successfully.
        Hide
        Ted Goddard added a comment -

        usePushService() might be called multiple times. Would this have any side effects? (From the code it looks like the eval could run multiple times, so this should likely be guarded against.)

        Show
        Ted Goddard added a comment - usePushService() might be called multiple times. Would this have any side effects? (From the code it looks like the eval could run multiple times, so this should likely be guarded against.)
        Hide
        Ted Goddard added a comment -

        Reopening to address potential issues from redundant initialization.

        Show
        Ted Goddard added a comment - Reopening to address potential issues from redundant initialization.
        Hide
        Mircea Toma added a comment -

        Implemented detection and blocking of redundant initialisation.

        Show
        Mircea Toma added a comment - Implemented detection and blocking of redundant initialisation.
        Hide
        Ted Goddard added a comment - - edited

        The following strange code was added to bridgeit.push:

                 if (ice && ice.push && ice.push.configuration.contextPath) {
        -            ice.push.notify(groupName, options);
        +            if (options && options.delay)  {
        +                ice.push.notify(groupName, options, options);
        +            } else {
        +                ice.push.notify(groupName, options);
        +            }
                 } else {
        
        

        We likely do not need separate options objects in the notify call.

        Show
        Ted Goddard added a comment - - edited The following strange code was added to bridgeit.push: if (ice && ice.push && ice.push.configuration.contextPath) { - ice.push.notify(groupName, options); + if (options && options.delay) { + ice.push.notify(groupName, options, options); + } else { + ice.push.notify(groupName, options); + } } else { We likely do not need separate options objects in the notify call.
        Hide
        Ted Goddard added a comment -

        Reopened to consider merged options parameter.

        Show
        Ted Goddard added a comment - Reopened to consider merged options parameter.
        Hide
        Ted Goddard added a comment -

        Comment from Deryk: If BridgeIt provides a general services platform, all services should be accessible in a uniform way. For instance, a single API key should be provided only once for both the push service, location service, and echo service.

        Instead of usePushService(), an extension would be useService("http://bridgeit.mobi","push","echo") which would dynamically download the required APIs and inject them under the bridgeit.* namespace using the first argument as the base service URL. The API key could be set in a separate call bridgeit.authorize(apikey).
        Note that this requires the dependent services to be BridgeIt-aware to add their APIs under bridgeit. (icepush.js could detect window.bridgeit and add the required functions.)

        Show
        Ted Goddard added a comment - Comment from Deryk: If BridgeIt provides a general services platform, all services should be accessible in a uniform way. For instance, a single API key should be provided only once for both the push service, location service, and echo service. Instead of usePushService(), an extension would be useService("http://bridgeit.mobi","push","echo") which would dynamically download the required APIs and inject them under the bridgeit.* namespace using the first argument as the base service URL. The API key could be set in a separate call bridgeit.authorize(apikey). Note that this requires the dependent services to be BridgeIt-aware to add their APIs under bridgeit. (icepush.js could detect window.bridgeit and add the required functions.)
        Hide
        Mircea Toma added a comment -

        Created issue PUSH-285 to define the merging of the 'options' parameter task.

        Show
        Mircea Toma added a comment - Created issue PUSH-285 to define the merging of the 'options' parameter task.
        Hide
        Ted Goddard added a comment -

        There are two forms of the API to load services:

        bridgeit.useService("http://api.bridgeit.mobi/","push","echo")

        Services at different base URLs can be specified with multiple invocations of useService().

        If the version of the service needs to be specified, the service can be registered in detail:

        bridgeit.useService("http://api.bridgeit.mobi/","push",

        {name: "echo", version: "2"}

        )

        Each service must have a script file stored at a well-known location, for instance:

        http://api.bridgeit.mobi/echo/echo.js

        The script echo.js will then add its API to the bridgeit object.

        Show
        Ted Goddard added a comment - There are two forms of the API to load services: bridgeit.useService("http://api.bridgeit.mobi/","push","echo") Services at different base URLs can be specified with multiple invocations of useService(). If the version of the service needs to be specified, the service can be registered in detail: bridgeit.useService("http://api.bridgeit.mobi/","push", {name: "echo", version: "2"} ) Each service must have a script file stored at a well-known location, for instance: http://api.bridgeit.mobi/echo/echo.js The script echo.js will then add its API to the bridgeit object.
        Hide
        Ted Goddard added a comment -

        Initial integration is implemented.

        Show
        Ted Goddard added a comment - Initial integration is implemented.

          People

          • Assignee:
            Mircea Toma
            Reporter:
            Ted Goddard
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: