I am trying to write simple chat based desktop support app. The gui is not problem, but I have problem with sending messages. The server sends it to all connected clients, but I want request and response to be private between server (or admin) and specific user. I have tried sockets and twisted, but can't figure out how to choose client to contact with.
So if there is any project like what I am trying to achieve on python 3 link or comment for reference. This is my school project for school local network.
Thanx in advance.
Related
I'm making a platform where people can play a card game together in the same room, but it's something that doesn't have a financial return, so I don't want to put the application on a server, instead, I want the person who created the room to play with friends can send their ip and their port (or something like this) so that others can connect to the room and exchange information between people in the room, using Socket.IO, how could I do that? If an http server for socket.io is needed to work, the person who created the room could be the server, if possible. (note: i'm making a desktop app using Electron.js)
I spend already 3 days for reading, watching tutorials about WebSockets, socket.io, node.js and so on.
Basically, I'm a Laravel developer and have just a basic idea about all the rest components.
With regret, after these 3 days I don't have in mind all logic step-by-step of implementing this architecture. I will try to explain what did I understand and you please correct me.
So :
WebSockets - is a bidirectional continuous connection between client and server. It uses another port, and basically it is not a HTTP/S connection.
For making this kind of app like I said, we need one more server, and idk why, but this is Node.js. At this Node.js server we should install socket.io (server-side package) and Redis.
Then, we need to add client-side socket.io (via CDN probably).
At Node.js server we are creating a server.js file where require all modules that we need, like socket.io and Redis. We open a connection for a specific non-used port (as 6001). Then we run this node server.
At front-end we are subscribe-ing to this channel and define method for emitting and listening to the server.
Example :
User1 is connecting to a specific route. User2 as well. User1 type a message for User2, when press Submit, message from User1 is sent to Node.js server, where it is sent in Redis(yes? if yes - Why?), and then Node.js is listening for what to do in this case, and send this message to specific user, or with broadcast to all users except the publisher.
Oh, it's even hard to explain that, too much steps and tehcnologies used.
Can please someone correct my logic? I really want to understand all that process and logic of using this components. Or please, give me some useful articles and videos, may be I didn't saw them. Thanks!
I suggest you read the official docs on how to build chat. Basically what you will have in the end is 2 servers, 1 for your Laravel app and the other for chat (Socket.io) . The key to this is using broadcasters and listening for events on both sides, frontend and backend.
Events are broadcast over "channels", which may be specified as public or private. Any visitor to your application may subscribe to a public channel without any authentication or authorization; however, in order to subscribe to a private channel, a user must be authenticated and authorized to listen on that channel.
I'm currently working on a project using Node.js and Socket.io and for the sockets, I use Redis as I subscribe to multiple channels.
The application signs a user in (Through an API -- Using OAuth) and what I basically want is to show is a list of people that are signed in (their avatar) but I'm struggling to work out how I would do this using the Redis server. I have tried to do this on connect but this does not work.
Can anyone recommend a way that I can do this effectively? Basically show the avatar of the user (or username) that are currently signed into the system.. It should be real-time so that's why I'm going down the socket direction.
Im using nodejs and socket.io to deliver a chat on my business app, but i want to distribute the deploy so i can have as many chat servers i want to balance the load of the traffic.
I try the load balance approach from nginx but that just do that balance the traffic but the communication between the socket.io serves its not the same, so one chat message send from user A to server S1 wont travel to user B on server S2.
There is any tool or approach to do this.
Thanks in advance.
===== EDIT =====
Here is the architecture of the app.
The main app frontend on PHP CodeIgniter lets tag it as PHPCI
The chat app backend on NodeJs and SocketIO lets tag it as CHAT
The chat model data on Redist lets tag it as REDIST
So what i have now its PHPCI -> CHAT -> REDIST. That work just fine.
What i need is to distribute the application so i can have as many PHPCI or CHAT or REDIST i want, example
PHPCI1 CHAT1
PHPCI2 -> -> REDIST1
PHPCI3 CHAT2
Where the numbers represent instances not different apps.
So a User A connected to PHPCI1 can send a message to a user B connected on PHPCI3.
I think some queue in the middle of CHAT can handle this something like rabbitmq that can only use the SocketIO to deliver the messages to the client.
If you're distributing the server load (and that's a requirement), I'd suggest adding a designated chat data server (usually an in-memory database or message queue) to handle chat state and message passing across edge servers.
Redis Pub/Sub is ideal for this purpose, and can scale up to crazy levels on even a low-end machine. The Redis Cookbook has a chapter on precisely this use case.
If you set up the server-side of your chat app correctly, you shouldn't have to distribute socket.io. Since node.js is browser-based and doesn't require any client-side code (other than the resources downloaded from the webpage), it works automatically. With a webpage, the files required to run socket.io are temporarily downloaded to users when they are correctly included (just like with jQuery). If you are using node.js and socket.io to make an android app, the files should be included in your application when you distribute it, not separately.
In addition, if you wish to use two separate socket.io servers, you should be able to establish communication between the two by connecting them in a similar manner that a client connects to the server, but with a special parameter that lets the other server know that a server connected and it can respond and set a variable for the other server.
I was going through some article and found that chat Clients are mostly p2p. If Google Talk is a p2p client then how is it able to save our chat in Gmail ?
The simple answer is that the audio is streamed from browser to browser without any server in between using the Jingle protocol.
So things like text chat and audio chat is peer-to-peer whereas all other functionality is provided by Google servers.
he chat it self uses Jabber (XMPP), but conversation logs are automatically saved to a Chats area in the user's Gmail account. This means that chats involve three parties (your computer, your mates computer and Googles Gmail server cluster)