Beispiel #1
0
 /// <summary>
 /// Raises an event on the client
 /// </summary>
 /// <param name="eventName">the name of the server-event</param>
 /// <param name="sessionId">the session for which to raise the event</param>
 /// <param name="arguments">the arguments for the raised event</param>
 protected override async Task RaiseEvent(string eventName, string sessionId, object[] arguments)
 {
     var response = await hubClient.InvokeServiceAsync(sessionId, JsonHelper.ToJsonStrongTyped(new EventNotificationMessage
     {
         EventName = eventName,
         Arguments = arguments
     }));
 }
Beispiel #2
0
        /// <summary>
        /// Implements a method to check on the remote object whether a specific object is available
        /// </summary>
        /// <param name="uniqueName">the unique name of the desired object</param>
        /// <returns>an object that provides information about the proxy-availability</returns>
        protected override ObjectAvailabilityResult CheckForAvailableProxy(string uniqueName)
        {
            if (ValidateConnection())
            {
                var msg = new ObjectAvailabilityRequestMessage
                {
                    UniqueName        = uniqueName,
                    AuthenticatedUser = identityProvider?.CurrentIdentity
                };

                var response = TestMessage <ObjectAvailabilityResponseMessage>(connection.InvokeServiceAsync(targetService, JsonHelper.ToJsonStrongTyped(msg, true))).ConfigureAwait(false).GetAwaiter().GetResult();
                return(new ObjectAvailabilityResult {
                    Available = response.Available, Message = response.Message
                });
            }

            return(new ObjectAvailabilityResult
            {
                Available = false,
                Message = "Service is unavailable!"
            });
        }