Skip to content
This repository was archived by the owner on Sep 20, 2022. It is now read-only.
This repository was archived by the owner on Sep 20, 2022. It is now read-only.

Client.Emit does not properly send object[] as multiple arguments. #11

@Metric

Description

@Metric

So, I was trying this out today, and noticed that the issue is it wraps the object[] into another object[]. I noticed that you had already supported it in the JSONEncodedEventMessage via the constructor of JsonEncodedEventMessage(string name, object[] payloads).

However, by trying to just use the Client.Emit it sends the object[] as just an object and thus only calls the JSONEncodedEventMessage(string name, object payload).

To fix this Add the following lines to Client.cs:

public void Emit(string eventName, Object[] payloads) {
this.Emit (eventName, payloads, string.Empty, null);
}

public void Emit(string eventName, Object[] payloads, string endPoint, Action<Object> callback) {
            IMessage msg = null;
            if (!string.IsNullOrEmpty(endPoint) && !endPoint.StartsWith("/"))
                endPoint = "/" + endPoint;
            msg = new EventMessage(eventName, payloads, endPoint, callback);
            if (callback != null)
                this.registrationManager.AddCallBack(msg);

            this.Send(msg);
        }

Then in EventMessage.cs add the following:

public EventMessage(string eventName, object[] payloads, string endpoint, Action<Object> callBack) : this() {
            this.Callback = callBack;
            this.Endpoint = endpoint;

            if (callBack != null)
                this.AckId = EventMessage.NextAckID;

            this.JsonEncodedMessage = new JsonEncodedEventMessage(eventName, payloads);
            this.MessageText = this.Json.ToJsonString();
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions