private void sendHumanMessage(HumanUser user, string message) { HumanUser partner = user.Partner; if (partner != null) { Clients.Caller.onMessageReceived(message, true); Clients.Client(partner.ConnectionId).onMessageReceived(message, false); } }
private void FindHumanPartner(HumanUser user) { HumanUser partner = (HumanUser)ConnectedUsers .Find(x => x is HumanUser && x != user && ((HumanUser)x).Partner == null); if (partner != null) { user.Partner = partner; partner.Partner = user; Clients.Caller.onPartnerJoined(); Clients.Client(partner.ConnectionId).onPartnerJoined(); } }
private User CreateNewUser(string connId, int siteId) { User newUser; if (FlipCoin()) { newUser = new BotUser(connId, siteId); } else { newUser = new HumanUser(connId, siteId); } return(newUser); }
public void GuessPartnerIsHuman() { User user = GetCurrentUser(); if (user != null) { if (user is HumanUser) { HumanUser humanUser = (HumanUser)user; ChangeHumanRank(humanUser.Partner, Constants.HUMAN_RANK_CHANGE); Win(user); } else if (user is BotUser) { Lose(user); } } }
public override Task OnDisconnected(bool stopCalled) { User user = GetCurrentUser(); if (user != null) { if (user is HumanUser) { HumanUser partner = ((HumanUser)user).Partner; if (partner != null) { Clients.Client(partner.ConnectionId).onPartnerLeft(); } } ConnectedUsers.Remove(user); } return(base.OnDisconnected(stopCalled)); }