Example #1
0
    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);
        }
    }