Best practice to implement sending message to custom groups in SignalR -


i developing real time multiplayer game using signalr. message delivery logic not simple not handle using groups.

for example, 1 message delivered users custom property equals dynamic value. means target audiance can not handled by

clients.all clients.allexcept 

i have mapping class this:

public class player {   public dynamic client { get; set; }    public string connectionid { get; set; }    public string name { get; set; } } 

somehow detect audiences in list object.

what best way send message in list? enumerating through list , calling

        foreach (var loopplayer in players)         {             player.client.sendmessage(message);         } 

or

        list<string> ids = new list<string>();         foreach (var loopplayer in players)         {             ids.add(item.connectionid.tostring());         }          clients.clients(ids).sendmessage(message); 

my concern first 1 is, serialize message every time. second one, don't know how working behind scene.

the both approach working concerning performance , trying find best practice. or other approach might use?

as said, enumerating on list of clients serialize message each , every time (and store serialized messages in internal buffers etc etc). if message same, unnecessary cpu\memory overhead. clients.clients(ids) serializes message once performance vise, way go.

the message delivery logic not simple not handle using groups. example, 1 message delivered users custom property equals dynamic value.

groups work in scaleout scenario out of box huge benefit if ever find in need scaleout. maybe try find way simplify "group assigment logic" @ cost of delivering messages more clients , doing "filtering" client side...


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -