Broadcast
yöntemi, WebSocketCollection
sınıfında tanımlanmıştır. WebSocketCollection
üzerinde bir LINQ sorgusu uygularken, Broadcast
yöntemine sahip olmayan bir IEnumerable<WebSocketHandler>
olsun.
Yeni WebSocketCollection
oluşturup sonra böyle Add
yöntemi kullanarak öğeleri tek tek ekleyebilirsiniz: Böyle bir uzantısı yöntem haline bu mantığı sarabilirdiniz
var handlers = group.Except(group.Where(r=>((MicrosoftWebSockets)r).user_id==1));
var collection = new WebSocketCollection();
foreach(var item in handlers)
{
collection.Add(item);
}
collection.Broadcast("Message");
:
public static class ExtentionMethods
{
public static WebSocketCollection ToCollection(this IEnumerable<WebSocketHandler> handlers)
{
var collection = new WebSocketCollection();
foreach (var item in handlers)
{
collection.Add(item);
}
return collection;
}
}
Ve bu şekilde kullanın:
group.Except(group.Where(r=>((MicrosoftWebSockets)r).user_id==1))
.ToCollection()
.Broadcast("Message");
w ah, senin LINQ sorgusu böyle koşulunu olumsuzlaştırılmasıyla daha iyi bir şekilde yapılabilir:
group.Where(r=> !(((MicrosoftWebSockets)r).user_id == 1))
.ToCollection()
.Broadcast("Message");
varacak bu iş '((WebSocketCollection) group.Except (group.Where (r => ((MicrosoftWebSockets) r) .user_id == 1))) Broadcast ("İleti") ' –
Bu hatayı aldığımda hata alıyorum 'Microsoft'un adını yazmak için' d__72'1 [Microsoft.Web.WebSockets.WebSocketHandler] yazın .Web.WebSockets.WebSocketCollection'. –
deepakgates