[-] Allah@lemm.ee 0 points 2 weeks ago

i thought iran's proxy hamas started october 7

[-] Allah@lemm.ee 0 points 3 weeks ago

but they also stated that

The grim procedure of winding down the business took over as passwords and laptops were collected while servers were backed up in case "some future incarnation of the business can be preserved".

which means maybe there is chance someone might pick it up in future

[-] Allah@lemm.ee 0 points 1 month ago

no joke, i got banned from lemmy.cafe for saying pineapple pizza bad, definitely avoid it

39
submitted 1 month ago by Allah@lemm.ee to c/news@lemmy.world
8
submitted 1 month ago by Allah@lemm.ee to c/news@lemmy.world
80
submitted 1 month ago by Allah@lemm.ee to c/lemmyshitpost@lemmy.world
5
submitted 1 month ago by Allah@lemm.ee to c/technology@lemmy.world
[-] Allah@lemm.ee -1 points 1 month ago

any proof that most muslims have bad belief?

[-] Allah@lemm.ee -1 points 1 month ago

yeah that's my middle name, i don't think i can change your mind but i will say this that majority of followers of islam have bad beliefs

19
submitted 1 month ago by Allah@lemm.ee to c/asklemmy@lemmy.world
-17
thoughts on this website? (takeoffspeeds.com)
0
submitted 1 month ago by Allah@lemm.ee to c/news@lemmy.world
1
submitted 1 month ago by Allah@lemm.ee to c/lemmyshitpost@lemmy.world
0
submitted 1 month ago by Allah@lemm.ee to c/news@lemmy.world
62
[-] Allah@lemm.ee -1 points 1 month ago* (last edited 1 month ago)

what? i think you mean drill?

-13
submitted 1 month ago* (last edited 1 month ago) by Allah@lemm.ee to c/casualconversation@lemm.ee

try using this code do you think it will work?

Below is a minimal example of how you can add a real‐time chat box that only your authenticated users can use. It uses:

  • Node.js + Express for the web server
  • express‐session to track logged-in users
  • Socket.io for real-time messaging

You’ll need to adapt the authentication check to however you store your users (database, JWTs, etc.), but this will give you the core of “only logged‐in folks see/use the chat.”


1. Install dependencies

npm init -y
npm install express express-session socket.io

2. server.js

const express = require('express');
const http    = require('http');
const session = require('express-session');
const SocketIO = require('socket.io');

const app = express();
const server = http.createServer(app);
const io = new SocketIO(server);

// 1) Session middleware
const sessionMiddleware = session({
  secret: 'YOUR_SESSION_SECRET',
  resave: false,
  saveUninitialized: false,
  // store: you can add a store like connect-mongo here
});
app.use(sessionMiddleware);

// 2) Make session available in socket.handshake
io.use((socket, next) => {
  sessionMiddleware(socket.request, socket.request.res || {}, next);
});

// Serve static files (our chat page + JS)
app.use(express.static('public'));

// 3) A simple “login” route for demo purposes.
//    In real life you’d check a DB, hash passwords, etc.
app.get('/login', (req, res) => {
  // e.g. ?user=alice
  const username = req.query.user;
  if (!username) return res.sendStatus(400);
  req.session.user = { name: username };
  res.redirect('/chat.html');
});

// 4) Protect chat page
app.get('/chat.html', (req, res, next) => {
  if (!req.session.user) return res.redirect('/login.html');
  next();
});

// 5) Handle socket connections
io.on('connection', socket => {
  const req = socket.request;
  if (!req.session.user) {
    // kick out any un‐authenticated socket
    return socket.disconnect(true);
  }

  const user = req.session.user.name;
  socket.broadcast.emit('message', {
    from: 'SYSTEM',
    text: `${user} has joined the chat`
  });

  socket.on('message', msg => {
    io.emit('message', {
      from: user,
      text: msg
    });
  });

  socket.on('disconnect', () => {
    socket.broadcast.emit('message', {
      from: 'SYSTEM',
      text: `${user} has left the chat`
    });
  });
});

server.listen(3000, () => {
  console.log('Listening on http://localhost:3000/');
});

3. public/chat.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Chat Room</title>
  <style>
    #messages { list-style: none; padding: 0; max-height: 300px; overflow-y: scroll; }
    #messages li { margin: 5px 0; }
    #form { display: flex; }
    #input { flex: 1; }
  </style>
</head>
<body>
  <h1>Chat Room</h1>
  <ul id="messages"></ul>
  <form id="form">
    <input id="input" autocomplete="off" placeholder="Type a message…" /><button>Send</button>
  </form>

  <script src="/socket.io/socket.io.js"></script>
  <script>
    const socket = io();

    const form = document.getElementById('form');
    const input = document.getElementById('input');
    const messages = document.getElementById('messages');

    socket.on('message', msg => {
      const li = document.createElement('li');
      li.textContent = `${msg.from}: ${msg.text}`;
      messages.appendChild(li);
      messages.scrollTop = messages.scrollHeight;
    });

    form.addEventListener('submit', e => {
      e.preventDefault();
      if (input.value.trim()) {
        socket.emit('message', input.value);
        input.value = '';
      }
    });
  </script>
</body>
</html>

4. How It Works

  1. Session setup We use express-session so that when a user “logs in” (e.g. via your existing form/database), we store { user: { name: '…' } } in req.session.

  2. Socket authentication By re-using the same session middleware in Socket.io’s io.use(…), every incoming socket has access to socket.request.session. If there’s no session.user, we immediately disconnect() them.

  3. Real-time chat

    • On connect/disconnect we broadcast a system message.
    • On client‐side, every message the user sends is emitted and broadcast to all.
  4. Protecting the page We guard chat.html in Express so that if you go there directly, you’ll get bounced to /login.html (you’d build a real login page).


Next Steps

  • Integrate with your real user database. Replace the demo /login route with your own logic.
  • Persist chat history if you want to store messages (e.g. in MongoDB or MySQL).
  • Add rooms or private messaging by namespace or room support in Socket.io.
  • Style it and embed it in your existing layout (lemm.ee) CSS.
52
submitted 1 month ago by Allah@lemm.ee to c/technology@lemmy.world
[-] Allah@lemm.ee 0 points 1 month ago

do you think my list is enough?

[-] Allah@lemm.ee -1 points 1 month ago

hmmm never thought about it that way

[-] Allah@lemm.ee 0 points 2 months ago

THIS WORKS

thanks alot fellow lemming here is a video of our lord in his habitat as a token of my gratitude

[-] Allah@lemm.ee -1 points 2 months ago

or just ask it to incinerate it inside

view more: ‹ prev next ›

Allah

joined 2 months ago