locked
SignalR Groups method Add() and Remove() method RRS feed

  • Question

  • User1135166864 posted

    Hey guys, 

    I have a question wanna ask, if I invoke the Groups.Add() method to add the connectionid to a specify group. if I have already add this connectionid to this group. does this call will be occurs error. 

    the same with Groups.Remove(), if I remove a connectionid doesn't exist in the group specified, does that occurs error.

    Monday, July 13, 2015 3:23 AM

Answers

  • User71929859 posted

    AFAIK, no. Trying to add an existing connection ID or, trying to remove an connection ID which does not exist in the group specified, does not give you an error or exception. It will just ignore it since the connection ID is already there/removed.

    But note that trying to call await on Groups.Remove() and if the connection ID is already removed from the specified group, then it will throw an TaskCanceledException.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, July 18, 2015 2:24 AM

All replies

  • User-1926401737 posted

    Hi Braveman,

    I have a question wanna ask, if I invoke the Groups.Add() method to add the connectionid to a specify group. if I have already add this connectionid to this group. does this call will be occurs error. 

    the same with Groups.Remove(), if I remove a connectionid doesn't exist in the group specified, does that occurs error.

    I’m not sure if it will cause any error, but you could try to join/leave a group for many times with a connectionid to check if it throws any error.

    ChatHub.server.joinGroup("yourgroupname");

    With Regards,

    swing

    Tuesday, July 14, 2015 5:22 AM
  • User71929859 posted

    AFAIK, no. Trying to add an existing connection ID or, trying to remove an connection ID which does not exist in the group specified, does not give you an error or exception. It will just ignore it since the connection ID is already there/removed.

    But note that trying to call await on Groups.Remove() and if the connection ID is already removed from the specified group, then it will throw an TaskCanceledException.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, July 18, 2015 2:24 AM