how to found a match in pusher or pubnub like quizup app - pusher

How can match two opponents. Lets say i have 10 opponents online and ready for match. I assume being online and ready for match are two subscribed channels after user interactions. Shortly i want to achieve Quizup iphone app like system.
how to found a match

PubNub Player Match Making like QuizUp App
When it comes to multiplayer gaming, matchmaking is essential for matching up two or more players in a multiplayer game. In this blog post, we’ll walk you through our matchmaking algorithm for random matchmaking (matching up two random users).
Matchmaking Algorithm: Random Matchmaking
Adding a "Find Match" Button.
Learn how Matchmaking for Multiplayer Games with PubNub can be accomplished.
Check out the full matchmaking demo on CodePen. In the next chapter, we’ll make matchmaking a smarter by adding skill levels into the mix, then we’ll enable users to challenge one another.
Matchmaking Algorithm: Skill-based Matchmaking
Learn how Matchmaking Algorithm: Skill-based Matchmaking can be accomplished.
We can show the skill level of each user in the list of online users. The same state object we defined earlier is returned as the data property of the user object when the presence event is fired from pubnub.subscribe.

Related

NodeJS and Socket.io creating room with two users

I'm doing chat app and I want to do it real time. Chat will be for now between two users. When user access to chat it finds all messages between them and displays messages. I think I need to create room with two users and then store room id in database. But I'm new to socket.io and I need advice how to do it.
Try to take some already pretty wide used chat, like Slack, as example. Usually you need pretty same set of things, workplaces, channels, private messages (like room but for two users only), and have users sending text messages with some formatting or images or just any files. Just take it easy, plan and make it step by step.
Also take note, that for both parties have their chat view updated with new messages you need not only save message one user send to db, but also broadcast that message to everyone, involved in conversation.

Creating a bot that manages currency for both a twitch chat and a discord server

I've built the currency system for both discord and twitch independently in node.js. I want my currency system to carry over between the two. The hard part is both discord and twitch use different user ids so I can't use one JSON file to manage both. Is there a way I can match up user ids easily (like if they have their twitch connected to the discord) or will I have to pair them up one by one manually?
There is NO EASY way todo this...
You will have to request each new user to connect their account...
How you can do this:
Step 1: ask them if they have a twitch account. If they dont you cant connect em
Step 2: send them a random sentence. EG:(Spiders Balloony Video Moles Havoc) (in DM)
Step 3: Ask them to repeat this sentence in a chat that the bot shares.
Step 4: When you find the sentence in the opposite chat you now know the user.
If twitch has DM chat you can do this vice versa as well! (I do not have a twitch account so I do not know if twitch has private chat)
At the moment that's not possible, because in order to see users' connections (like Twitch profile, YouTube channel and so on...) you'd need a self-bot (that can get you banned from Discord).
Discord Dreamland has an active idea on this topic: link
See also this other question

how to get global presence for pusher

I'm building a chat application and I'd like to get a list of which of the people I'm following are online and what chat rooms they are in.
According to the pusher docs, the presence channels are per channel and
This is not the same as jabber style “which of my friends are online” presence.
Pusher doesn’t offer anything out of the box for that use case right now.
https://pusher.com/docs/client_api_guide/client_presence_channels
So if I were to create this feature on pusher, should I just create a global channel and have everyone connect to that silently in the background to get a global presence - if so there is a 100 person limit to that so it wouldn't be feasible. Or should I just create a single channel per user and then let users subscribe to a channel per each person they are friends with (though that seems a bit inefficient)? Note that this is a one way people I am following relationship and not a 2-way friend relationship.
As you pointed out Presence channels are more for rooms of up to 100 users.
Note: The thinking behind that is that a room with more than that isn't really a chat session. Hopefully this restriction will change in the future and it will increase the use case for presence channels.
To get a count of the number of the users you follow who are online you'll need to ensure each user is subscribed to a user-specific channel (e.g. myUserId-channel or private-myUserId-channel if auth is required) and then query the Pusher HTTP API and check to see if a user-specific channel is occupied. If it is then that user is subscribed to the channel and thus online. See Querying Application Channels.
For a more detailed description see Using presence for large groups of users.

Which technique is best suited for chat-like app

I want to develop a mobile app where a registered user can search among other registred users. User A can chat with user B. User A can view user B's profile. Upon this, user B have to be informed that user A is watching him.
So its some kind of chatroom where the server should be able to be notified when a user watched/contact another user, and let the latter know about this.
My first idea was to use node.js. But I begun to read a lot on XMPP-protocol. Do you think an XMPP-server would be more adequate to this kind of app? What I udnerstand you can customize your xmpp-server, write plugins so it can behave the way you want. Is this correct?
This is a perfect use case for socket IO using NodeJS. In fact, I have implemented exactly what you are describing with an iOS client and node backend in less than 50 lines of code. See https://github.com/MegaBits/SIOSocket for the iOS library, and http://socket.io/ for SocketIO.
XMPP is much heavier and verbose, and you'll be spending a lot of time parsing/building XML when you could just be communicating in JSON all the way. Take a look at my repo here:
https://github.com/alhill10/chatapp3/blob/master/View%20Control%20App/ChatView.m#L34
You can see on the viewDidLoad method it simply opens a websocket connection and listens for events from the server, then updates the tableview being used as a chat window with any new incoming messages in real time.
Then, look here https://github.com/alhill10/simplechat/blob/master/app.js for a simple example of the Socket IO backend that receives and relays the messages, as well as maintaining the state of current users online. You could trivially add in user authentication and .

Socket.IO multiple pages for same user/socket

I'm working on a multiplayer board game on Node.js/Socket.IO. The flow is the following :
user enters his name and is added to the lobby
user select a room and is added to it, then game starts when he is joined by another user.
This part is petty easy and I've done it before. However, I now need the user to be able to join multiple game rooms at the same time. pages are dynamically generated by express, and there's no issue opening many game pages, but I'm struggling with the socket implementation.
Can I use a single socket for multiple rooms (for the same user) or do I have to create a new socket per room?
I'd like the user to always be able to chat within the lobby while in game. How do I sort that out?
Thanks
However, I now need the user to be able to join multiple game rooms at the same time. pages are dynamically generated by express, and there's no issue opening many game pages [...] Can I use a single socket for multiple rooms (for the same user) or do I have to create a new socket per room?
Pages open separately by the user do not share any context with each other. There are some hacky ways (such as a Flash LocalConnection), but you never should rely on these. Therefore, each page requires its own connection to your server.
I'd like the user to always be able to chat within the lobby while in game. How do I sort that out?
However you want. That implementation is up to you. If you are currently using the Socket.IO "rooms" feature, I suggest not using it so you have maximum flexibility in your implementation.

Resources