Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hub.invoke(...) Won't handle any response. #111

Open
F-Forget opened this issue Mar 31, 2018 · 0 comments
Open

hub.invoke(...) Won't handle any response. #111

F-Forget opened this issue Mar 31, 2018 · 0 comments

Comments

@F-Forget
Copy link

Hi! 😄

First of all, I want to say thanks to @adamhartford for giving us this amazing Signal R wrapper!

Alright, I’m really stuck with something here. I need to handle a response from my C# server that return an IEnumerable of Guid (IEnumerable). Here’s my code:

    do {
        if let hub = drawView.drawingHub {
            
            try hub.invoke("AddStrokes", arguments: [[strokeDataDictionary]]) { (result, error) in
                if let e = error {
                    print("Error: \(e)")
                } else {
                    print("Success!")
                    if let r = result {
                        // Assing Stroke Is's...
                        // currentStroke.Id = result...
                    }
                }
            }
        }
    }
    catch {
        //handle error
        print(error)
    }

After trying couple of times, my code after the invoke is never getting called, even if my server returns an answer on is the side.

Does anyone have any advice? I know my server is working find on other C# clients. After debugging on the server side, I should correctly return a List of GUIDs. For debugging purposes, here’s my server code:

    public IEnumerable<Guid> AddStrokes(List<StrokeData> strokes)
    {
        string drawingSession = DrawingSessionService.Instance.GetCurrentDrawingSession(Context.ConnectionId);
        if(!String.IsNullOrEmpty(drawingSession))
        {
            List<Guid> strokeGuids = new List<Guid>();
            foreach(StrokeData stroke in strokes)
            {
                if (stroke.Id == Guid.Empty)
                {
                    stroke.Id = Guid.NewGuid();
                }
                strokeGuids.Add(stroke.Id);
            }
            DrawingSessionService.Instance.GetDrawingData(drawingSession)?.AddStrokes(strokes);
            Clients.Group(drawingSession, Context.ConnectionId).AddStrokes(strokes);
            return strokeGuids;
        }
        return null;
    }

Does anyone have any idea?

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant