Exemplo n.º 1
0
        private void OnBind(string msg, string reply, string subject)
        {
            Logger.Debug(Strings.BindRequestLogMessage, ServiceDescription(), msg, reply);
            BindResponse response     = new BindResponse();
            BindRequest  bind_message = new BindRequest();

            bind_message.FromJsonIntermediateObject(JsonConvertibleObject.DeserializeFromJson(msg));
            string name = bind_message.Name;

            // Create a service credentials object with a name set, so we can run this operation in parallel for different service instances.
            ServiceCredentials nameCredentials = new ServiceCredentials();

            nameCredentials.Name = name;

            nameCredentials.ServiceWorkFactory.StartNew(
                () =>
            {
                try
                {
                    Dictionary <string, object> bind_opts = bind_message.BindOptions;
                    ServiceCredentials credentials        = bind_message.Credentials;
                    response.Credentials = this.Bind(name, bind_opts, credentials);
                    NodeNats.Publish(reply, null, EncodeSuccess(response));
                }
                catch (Exception ex)
                {
                    Logger.Warning(ex.ToString());
                    NodeNats.Publish(reply, null, EncodeFailure(response, ex));
                }
            });
        }
Exemplo n.º 2
0
        private void OnBind(string msg, string reply, string subject)
        {
            Logger.Debug(Strings.BindRequestLogMessage, ServiceDescription(), msg, reply);
            BindResponse response = new BindResponse();
            BindRequest bind_message = new BindRequest();
            bind_message.FromJsonIntermediateObject(JsonConvertibleObject.DeserializeFromJson(msg));
            string name = bind_message.Name;

            // Create a service credentials object with a name set, so we can run this operation in parallel for different service instances.
            ServiceCredentials nameCredentials = new ServiceCredentials();
            nameCredentials.Name = name;

            nameCredentials.ServiceWorkFactory.StartNew(
                () =>
                {
                    try
                    {
                        Dictionary<string, object> bind_opts = bind_message.BindOptions;
                        ServiceCredentials credentials = bind_message.Credentials;
                        response.Credentials = this.Bind(name, bind_opts, credentials);
                        nodeNats.Publish(reply, null, EncodeSuccess(response));
                    }
                    catch (Exception ex)
                    {
                        Logger.Warning(ex.ToString());
                        nodeNats.Publish(reply, null, EncodeFailure(response, ex));
                    }
                });
        }