private void DisconnectEvent(int recHostId, int cnnId) { Debug.Log(string.Format("User {0} has Disconnected..", cnnId)); // get a reference to the connected account Model_Account account = db.FindAccountByConnectionId(cnnId); if (account == null) { // making sure athenticated return; } db.UpdateAccountAfterDisconnection(account.Email); // Prepare and send update message Net_UpdateFollow fu = new Net_UpdateFollow(); Model_Account updatedAccount = db.FindAccountByEmail(account.Email); fu.Follow = updatedAccount.GetAccount(); foreach (var f in db.FindAllFollowBy(account.Email)) { if (f.ActiveConnection == 0) { continue; } SendClient(recHostId, f.ActiveConnection, fu); } }
private void LoginRequest(int cnnId, int channelId, int recHostId, Net_LoginRequest lr) { // Debug.Log(string.Format("{0},{1}",lr.UsernameOrEmail,lr.Password)); string randomToken = Utility.GenerateRandom(4); //Change to 256 on production Model_Account account = db.LoginAccount(lr.UsernameOrEmail, lr.Password, cnnId, randomToken); Net_OnLoginRequest olr = new Net_OnLoginRequest(); if (account != null) { olr.Success = 1; olr.Information = "You have been logged in as" + account.Username; olr.Username = account.Username; olr.Discriminator = account.Discriminator; olr.Token = account.Token; olr.ConnectionId = cnnId; // Here // Prepare and send update message Net_UpdateFollow fu = new Net_UpdateFollow(); fu.Follow = account.GetAccount(); foreach (var f in db.FindAllFollowBy(account.Email)) { if (f.ActiveConnection == 0) { continue; } SendClient(recHostId, f.ActiveConnection, fu); } } else { olr.Success = 0; } SendClient(recHostId, cnnId, olr); }
private void OnUpdateFollow(Net_UpdateFollow fu) { HubSceneHandler.Instance.UpdateFollow(fu.Follow); }