public void Connect(string userName, string userPw) { if (Gruplar.GrupListesi.Count == 0) { Gruplar.GrupListesi = Gruplar.GrupYukle(); } var id = Context.ConnectionId; if (ConnectedUsers.Count(x => x.ConnectionId == id) == 0) { DBControls.LoginClass loginSonuc = DBControls.SQLLoginControl(userName, userPw); if (loginSonuc.durum == true) { DBControls.UserDetail yeniUser = DBControls.GetUserInfo(userName, id); ConnectedUsers.Add(yeniUser); Gruplar.KullanıcıEslestir(yeniUser.UserID, yeniUser.ConnectionId); ////send to caller //Clients.Caller.onConnected(id, userName, ConnectedUsers, CurrentMessage); ////send to all except caller client //Clients.AllExcept(id).onNewUserConnected(id, userName); Clients.Client(id).connectMessage("kabul", loginSonuc.id.ToString()); } else { Clients.Client(id).connectMessage("red", "0"); } } }
public void AddNewGroup(List <string> users, string name) { DBControls.DBNewGroup(users, name); var id = Context.ConnectionId; Clients.Client(id).addnewGroup("ok"); Gruplar.GrupYenile(); }
//public void SendMessageToAll(string userName, string message) //{ // // store last 100 messages in cache // AddMessageinCache(userName, message); // // Broad cast message // Clients.All.messageReceived(userName, message); ////} //public void SendPrivateMessage(string toUserId, string message) //{ // string fromUserId = Context.ConnectionId; // var toUser = ConnectedUsers.FirstOrDefault(x => x.ConnectionId == toUserId); // var fromUser = ConnectedUsers.FirstOrDefault(x => x.ConnectionId == fromUserId); // if (toUser != null && fromUser != null) // { // // send to // Clients.Client(toUserId).sendPrivateMessage(fromUserId, fromUser.UserName, message); // // send to caller user // Clients.Caller.sendPrivateMessage(toUserId, fromUser.UserName, message); // } //} public override Task OnDisconnected() { string connectionid = Context.ConnectionId; var item = ConnectedUsers.FirstOrDefault(x => x.ConnectionId == connectionid); if (item != null) { ConnectedUsers.Remove(item); if (Gruplar.GrupListesi.Count != 0) { Gruplar.GrupdanUyeDusur(item, connectionid); } //var id = Context.ConnectionId; //Clients.All.onUserDisconnected(id, item.UserName); } return(base.OnDisconnected()); }