Photon Chat to invite friend to room?
Using C++ Realtime in Unreal Engine 4, targeting Android C++ and iOS C++.
So I just got friend searching setup. You can see if the friends in your friend list are online or not.
What I need to be able to do is allow a player to invite one of their friends to a private room. So essentially, to notify the friend that a match request has been made, and give them the option the accept the request and join the room should they accept.
I've read that clients cannot communicate to each other in the lobby, so there is no way to send some kind of event to your online friend that would trigger the in-game match request.
It's really important that we can have this feature.
Is there some workaround using Photon Chat that would allow a player in the lobby to invite another player in the lobby (by name, of course) to a private match?
Or really, just any way to invite someone to a private room that doesn't involve both clients manually setting it up (one invites, the other gets the invite)
So I just got friend searching setup. You can see if the friends in your friend list are online or not.
What I need to be able to do is allow a player to invite one of their friends to a private room. So essentially, to notify the friend that a match request has been made, and give them the option the accept the request and join the room should they accept.
I've read that clients cannot communicate to each other in the lobby, so there is no way to send some kind of event to your online friend that would trigger the in-game match request.
It's really important that we can have this feature.
Is there some workaround using Photon Chat that would allow a player in the lobby to invite another player in the lobby (by name, of course) to a private match?
Or really, just any way to invite someone to a private room that doesn't involve both clients manually setting it up (one invites, the other gets the invite)
0
Comments
-
Hi DG Gage.I've read that clients cannot communicate to each other in the lobby, so there is no way to send some kind of event to your online friend that would trigger the in-game match request.
You would either need to use a 3rd party service for this (for example Apples Game Center and push notifications for Apple devices - however tat would mean that those can' invite or be invited by Android devices and you would still need an alternative solution for Android) or you could indeed do this with the help of Photon Chat like described below.Is there some workaround using Photon Chat that would allow a player in the lobby to invite another player in the lobby (by name, of course) to a private match?
1. Create a LoadBalancing:Client instance.
2. Create a Chat::Client instance. Make sure that you pass the exact same value for the userid as you have done for the username in step 1.
3. Connect the LoadBalancing::Client instance to Photon Cloud.
4. Connect the Chat::Client instance to Photon Cloud.
5. Repeat steps 1-4 with a second client that uses a different username/-id than the first one.
6. Call LoadBalancing::Client::opFindFriends() with Client A to check, if Client B is online.
7. Call Chat::opSendPrivateMessage() on Client A with the username of Client B as recipient and your invitation as message (messages in Photon Chat are not restricted to text only. You can send any datatype that is supported by Photons serialization (for further information on supported data types please see http://doc-api.exitgames.com/en/realtim ... 00038.html).
8. Call LoadBalancing::createRoom() on Client A and specify the same room name that you have sent in the invitation.
9. On Client B identify the message as invitation and don't show it as a user readable-chat message, but instead read out the room name from it.
10. Let Client B call opJoinRoom() with the room name that it has received in the chat message.
11. You are done. Client B has successfully joined the room to which he has been invited by Client A.
12. Celebrate the successful implementation of a key feature of your game with the help of vanilla vodka and Diet Coke.0 -
Kaiserludi wrote:12. Celebrate the successful implementation of a key feature of your game with the help of vanilla vodka and Diet Coke.
You are just the best. Was that a reference to my profile on my website or just a sign of great minds thinking alike??
Also, this Realtime+Chat advice is great and was exactly what I was hoping for. Sounds very easy.
Looking at the Chat API, it seems to have enough differences in it from the Realtime API that it would be a lot of work to try to combine them into a single, mega API. Am I correct on this? I assume that's why you guys haven't just done it yourselves.
Unless you say otherwise, I will go ahead and implement Chat as a separate API and not bother trying to combine them, and get back to you with results.0 -
DG Gage wrote:Kaiserludi wrote:12. Celebrate the successful implementation of a key feature of your game with the help of vanilla vodka and Diet Coke.
You are just the best. Was that a reference to my profile on my website or just a sign of great minds thinking alike??DG Gage wrote:Kaiserludi wrote:Looking at the Chat API, it seems to have enough differences in it from the Realtime API that it would be a lot of work to try to combine them into a single, mega API. Am I correct on this? I assume that's why you guys haven't just done it yourselves.
You could write a wrapper class that holds both Clients and routes API calls and servers responses between the wrapped Client classes and the game code, if you prefer to have one single point of contact for your game code for everything network related.0 -
Just had the best 3 hours of my life.
And by that I mean, I am ready for that scrumptious cocktail you mentioned earlier.
So what I did is import (for UE4 that's an entirely different issue, which I could explain for anyone who sees this and is wondering how) the Chat API into my project, and into the same class that handles the Realtime import. And in my Source, I had Chat (API) and Photon (API), so they'd be in the same directory. As you can imagine, that did not go well.
However, by:
1. Adding Chat/ or Photon/ to all API directory #includes in all Chat API and Realtime API files, respectively
2. Adding Chat to the ExitGames namespace (so now ExitGamesChat) in all Chat API files
3. Changing FLOAT to EG_FLOAT in Chat API files (this is an issue specific to UE4 I believe)
I now have access to both APIs simultaneously from my UE4 class that handles everything network related!
That's probably what you meant by wrapper, but I'm new to coding so I barely even know what that means. Is that what it means?
And your help has been super awesome. I even originally got Photon because of your comments in the UE4 threads.
I imagine things should just go well from here, but who knows what kind of Chat questions I'll end up having???
*fist bump*0 -
And in my Source, I had Chat (API) and Photon (API), so they'd be in the same directory. As you can imagine, that did not go well.
PhotonDemoParticle-UE4 should have the following paths in it:
.\PhotonDemoParticle-UE4\Source\Photon\Common-cpp
.\PhotonDemoParticle-UE4\Source\Photon\Photon-cpp
.\PhotonDemoParticle-UE4\Source\Photon\LoadBalancing-cpp
.\PhotonDemoParticle-UE4\Source\Photon\libs
You would simply add another folder there:
.\PhotonDemoParticle-UE4\Source\Photon\Chat-cpp
Chat-cpp is Photon Chat specific, while Loadbalancing-cpp contains the Client API for Photon Realtime and Photon Turnbased. Common-cpp and Photon-cpp are shared and used by and with both, Chat and LB.
Number 3. of your list is a general UE4 specific issue, 1. and 2. should not be needed at all.
What I think is happening here is a version conflict:
I guess that you are using the Client library files that ship with the demo together with the Chat-cpp files from the latest Client SDKs in our download section.
This means that the versions of LoadBalancing-cpp and Chat-cpp that you use require different versions of Common-cpp and Photon-cpp which are not compatible to each other. So if you use only one version of Common-cpp and Photon-cpp, depending on which version you use either Chat-cpp or LoadBalancing-cpp will complain.
To avoid such conflicts, please make sure that all Photon library and header files in your project are from the same version.
So, just delete
.\YourProject\Source\Photon\Chat-cpp\inc
.\YourProject\Source\Photon\Common-cpp\inc
.\YourProject\Source\Photon\Photon-cpp\inc
.\YourProject\Source\Photon\LoadBalancing-cpp\inc
and all files in
.\YourProject\Source\Photon\libs.
Then download and unzip the latest versions of the iOS and the AndroidNDK Photon Client SDK from our download section.
Drop Chat-cpp\inc, Common-cpp\inc, Photon-cpp\inc, LoadBalancing-cpp\inc from one of those SDKs (doesn't matter which one) into .\YourProject\Source\Photon\ .
In each of the folders Chat-cpp, Common-cpp, Photon-cpp, LoadBalancing-cpp in the AndroidNDK SDK there is a subfolder lib\chat-cpp-prebuilt and in each of those folders in the iOS SDK there is a subfolder named lib. Navigate to all those 8 subfolders and copy all the lib files in there into .\YourProject\Source\Photon\libs\Android (for the a. files from the AndroidNDK SDK) and .\YourProject\Source\Photon\libs\iOS (the .a files from the iOS SDK).I now have access to both APIs simultaneously from my UE4 class that handles everything network related!
That's probably what you meant by wrapper, but I'm new to coding so I barely even know what that means. Is that what it means?0 -
Ahhhh okay that totally makes sense! I was really confused why those files were only slightly different. I kinda feel dumb for not realizing it was a version difference issue.
Can't say I didn't learn something from my original method though! If anything, going through every single Photon file gave me a deeper understanding.
But anyway, I made sure all my files were up to date, and added Chat-cpp and the corresponding chat lib files to the platform lib directories.
Works like a charm, and only took like 10 minutes! Haha, once again, thank you so much for your help.0