How to create the Private chat system with Photon Chat?

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on Photon Chat.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

How to create the Private chat system with Photon Chat?

Albertkaruna
2017-05-26 06:08:48

I have almost done it but before showing the message it doesn't show the new messages.
if anyone has done the private chat system, please let me know how to do it.
Thank you...

Comments

JohnTube
2017-05-26 09:40:40

Hi @Albertkaruna,

Thank you for choosing Photon!

I don't understand what is the issue here.

Photon Chat allow you to send private messages from a single user to a single user using a single method call.

Albertkaruna
2017-05-27 10:03:20

I was tried but it wasn't working.
If you got any sample code, please show me that.

How to add players to private channel?

JohnTube
2017-05-29 07:49:16

Photon "private channels" can have only two users.
You can use "public channels" with a name shared between few users (more than 2) so it work as "private channels" others can't see/subscribe to unless they guess the name.

Albertkaruna
2017-05-29 09:16:32

I've tried to use the private chat but still, i can't get the result. The examples that you're given doesn't have any examples for a private chat. So, please give me some example code.
Thank you.

JohnTube
2017-05-29 11:21:55

To send private message:

chatClient.SendPrivateMessage(TargetUserId, message);

To recieve private message:

public class ChatClient : IChatClientListener {

public void OnPrivateMessage(string sender, object message, string channelName )  
{  
     
}

Albertkaruna
2017-05-29 13:37:15

Thank you @JohnTube . Now it's working fine.

JohnTube
2017-05-29 13:47:21

I just copy pasted the docs.

AjayBhojani
2018-01-18 06:40:24

hi...
is it possible to get TargetUserId ? I want all user ids who is connected.
Thanks in advance....!

Back to top