SignalR pegar lista de usuários e adicionar a um listview (VB.net)
Olá pessoal,
Sou novato em SignalR e estou com uma grande dúvida, como faço para pegar a lista de usuários on-line de um servidor SignalR/C# com um cliente em VB.net?
Utilizando javascript consigo pegar a lista normalmente porem não estou conseguindo criar o mesmo código em VB.net.
Alguém poderia me ajudar por favor?
Função que disponibiliza a lista no servidor:
public bool SendOnlineContacts()
{
try
{
OnlineContacts onlineContacts = new OnlineContacts();
foreach (var item in _chatUsers.OrderByDescending(a => a.Value.data))
{
onlineContacts.messageRecipients.Add(item.Value);
}
Clients.All.onGetOnlineContacts(onlineContacts);
return false;
}
catch (Exception)
{
throw new InvalidOperationException("Problem in getting contacts!");
}
}
-------------------------------------------------------------------------
Código em ASP:
<script type="text/javascript">
var Server;
$(document).ready(function () {
Server = $.connection.ChatHub;
$.connection.hub.start({ transport: 'auto', waitForPageLoad: true }, function () {
Server.server.connect("0123456", "Deu Certo!!!").fail(function (e){
});
});
Server.client.onGetOnlineContacts = function (chatUsers) {
ShowTable(chatUsers, Server);
};
});
function ShowTable(chatUsers, Server) {
console.log(chatUsers.messageRecipients);
if ($("#ListaUsuariosOnline").length) {
var html = "<table cellspacing='0' cellpadding='5' align='Center' style='font-size:10px; width=1024px;'>";
html += "<tr style='font-size:10px;'>";
html += "<th style='font-size:10px;'>Usuário ID</th><th style='font-size:10px;'>Nome/CPF</th><th style='font-size:10px;'>Filial</th><th style='font-size:10px;'>Página atual</th><th style='font-size:10px;'>Navegador</th><th style='font-size:10px;'>Data/Hora</th><th style='font-size:10px;'>Ações</th>";
html += "</tr>";
$.each(chatUsers.messageRecipients, function (index, value) {
html += "<tr>";
html += "<td>" + $(this)[0].messageRecipientId + "</td><td>" + $(this)[0].messageRecipientName + "</td><td>" + $(this)[0].data + "</td><td><input type='button' value='Enviar Msg' onclick=\"Server.server.enviacomando(prompt('Enviar mensagem à " + $(this)[0].messageRecipientName + "', ''), '" + $(this)[0].messageRecipientId + "', 'msg');\" class='btn cancel'> <input type='button' class='btn cancel' value='Enviar Commando' onclick=\"Server.server.enviacomando(prompt('Enviar comando à " + $(this)[0].messageRecipientName + "', ''), '" + $(this)[0].messageRecipientId + "', 'comando');\"></td>";
html += "</tr>";
});
html += "</table>";
var len = $.map(chatUsers.messageRecipients, function (n, i) { return i; }).length;
$("#ListaUsuariosOnlineTotal").html(len);
$("#ListaUsuariosOnline").html(html);
}
}
</script>Discussão (2)
Carregando comentários...