private void DisconnectEvent(int recievingHostId, int connectionId) { Debug.Log(string.Format("User {0} has disconnected :(", connectionId)); // Get a reference to the connected Account AccountModel dbAccount = db.FindAccountByConnectionId(connectionId); // Just making sure he was indeed authenticated if (dbAccount == null) { return; } db.UpdateAccountAfterDisconnection(dbAccount.Email); // Prepare and send our update message Net_FollowUpdate msg = new Net_FollowUpdate(); AccountModel updatedAccount = db.FindAccountByEmail(dbAccount.Email); msg.Follow = updatedAccount.GetAccount(); foreach (var f in db.FindAllFollowBy(dbAccount.Email)) { if (f.ActiveConnection == 0) { continue; } SendClient(recievingHostId, f.ActiveConnection, msg); } }
private void LoginRequest(int connectionId, int channelId, int recievingHostId, Net_LoginRequest msg) { string randomToken = Utility.GenerateRandom(64); AccountModel dbAccount = db.LoginAccount(msg.UsernameOrEmail, msg.Password, connectionId, randomToken); Net_OnLoginRequest rmsg = new Net_OnLoginRequest(); if (dbAccount != null) { rmsg.Success = 1; rmsg.Information = "You've been logged in as " + dbAccount.Username; rmsg.Username = dbAccount.Username; rmsg.Discriminator = dbAccount.Discriminator; rmsg.Token = randomToken; rmsg.ConnectionId = connectionId; // Prepare and send our update message Net_FollowUpdate fu = new Net_FollowUpdate(); fu.Follow = dbAccount.GetAccount(); foreach (var f in db.FindAllFollowBy(dbAccount.Email)) { if (f.ActiveConnection == 0) { continue; } SendClient(recievingHostId, f.ActiveConnection, fu); } } else { rmsg.Success = 0; } SendClient(recievingHostId, connectionId, rmsg); }
private void FollowUpdate(Net_FollowUpdate msg) { HubScene.Instance.UpdateFollow(msg.Follow); }