Class ServerConnector


  • public class ServerConnector
    extends Object
    Handles creating and sending messages to the server using ServerRpcQueue.
    Since:
    1.0
    • Constructor Detail

      • ServerConnector

        public ServerConnector​(Registry registry)
        Creates a new instance connected to the given registry.
        Parameters:
        registry - the global registry
    • Method Detail

      • sendNavigationMessage

        public void sendNavigationMessage​(String location,
                                          Object stateObject,
                                          boolean routerLinkEvent)
        Sends a navigation message to server.
        Parameters:
        location - the relative location of the navigation
        stateObject - the state object or null if none applicable
        routerLinkEvent - true if this event was triggered by interaction with a router link; false if triggered by history navigation
      • sendEventMessage

        public void sendEventMessage​(StateNode node,
                                     String eventType,
                                     elemental.json.JsonObject eventData)
        Sends an event message to the server.
        Parameters:
        node - the node that listened to the event
        eventType - the type of event
        eventData - extra data associated with the event
      • sendEventMessage

        public void sendEventMessage​(int nodeId,
                                     String eventType,
                                     elemental.json.JsonObject eventData)
        Sends an event message to the server.
        Parameters:
        nodeId - the id of the node that listened to the event
        eventType - the type of event
        eventData - extra data associated with the event
      • sendTemplateEventMessage

        public void sendTemplateEventMessage​(StateNode node,
                                             String methodName,
                                             elemental.json.JsonArray argsArray,
                                             int promiseId)
        Sends a template event message to the server.
        Parameters:
        node - the node that listened to the event
        methodName - the event handler method name to execute on the server side
        argsArray - the arguments array for the method
        promiseId - the promise id to use for getting the result back, or -1 if no result is expected
      • sendNodeSyncMessage

        public void sendNodeSyncMessage​(StateNode node,
                                        int feature,
                                        String key,
                                        Object value)
        Sends a node value sync message to the server.
        Parameters:
        node - the node to update
        feature - the id of the node map feature to update
        key - the map key to update
        value - the new value
      • sendExistingElementAttachToServer

        public void sendExistingElementAttachToServer​(StateNode parent,
                                                      int requestedId,
                                                      int assignedId,
                                                      String tagName,
                                                      int index)
        Sends a data for attach existing element server side callback.
        Parameters:
        parent - parent of the node to attach
        requestedId - originally requested id of a server side node
        assignedId - identifier which should be used on the server side for the element (instead of requestedId)
        tagName - the requested tagName
        index - the index of the element on the server side
      • sendExistingElementWithIdAttachToServer

        public void sendExistingElementWithIdAttachToServer​(StateNode parent,
                                                            int requestedId,
                                                            int assignedId,
                                                            String id)
        Sends a data for attach existing element with id server side callback.
        Parameters:
        parent - parent of the node to attach
        requestedId - originally requested id of a server side node
        assignedId - identifier which should be used on the server side for the element (instead of requestedId)
        id - id of requested element
      • sendReturnChannelMessage

        public void sendReturnChannelMessage​(int stateNodeId,
                                             int channelId,
                                             elemental.json.JsonArray arguments)
        Sends a return channel message to the server.
        Parameters:
        stateNodeId - the id of the state node that owns the channel.
        channelId - the id of the channel.
        arguments - array of arguments passed to the channel, not null.