Chat System Help

edited February 2011 in Photon Server
Anyone out there wanna share some sample code on how they did their chat system? I am a bit lost setting mine up.



  • Are you talking about unity? It is really easy:

    1- Create your own GUI: just to write and send (you can get it from unity chat examples).
    2- Create your own Operation (sendChatMessage for example): create your method in "Operations.cs", save the message and send it to the peer.
    3- Now in the peer, catch this operation code and process the operation, publishing an event to all subscribed items for example.
    4- All peers must catch this event and process it, showing the message in the chat GUI.

    It's just a summary but It is really easy if you understand Photon Architecture.

    Good luck dude!
  • I am working on a chat sample in Unity. Progress has been good today, so there's already a working chat that includes usernames and a button to leave the room. You can run multiple connections in a single client to make testing easier.
    So far, there's really few comments in code and I need to work on the gui a bit more (mark the username that's yours, etc) and add a debug window to make it work on devices without keyboard as well.
    I could certainly drop a "current state" zip in tomorrow.
  • Yeah chat sample will surely come in handy to everyone sooner or later. :)
  • I attached a first version here. It's not yet complete but I don't know how far I can get today.
    Upcoming: more comments, listing and selection of rooms, gui for the multi-peer part, debug out to screen and a bit of style. Maybe: autoscroll to last message.
    Inside: use property for name, join a chat room, listing of usernames, chat messages listing
  • I just added Lobby (room listing and selection) and a part of the documentation. It's all inline, so go take a look at the code ;)

    If anyone has feedback: now it's the time to get your ideas in.
  • Thanks Tobias. I am not working in Unity. I am writing an IPhone Game. App is in the Review Process at the moment.

    I got my chat system working by trial and error. I was having issues with the channels. Every time I tried to send the Chat Operation/Event to peers through a different channel other then default it wouldn't work. I'd like to rewrite my server logic to send them on a different channel but need to wait til app gets approved before i mess with it.

    I'll look at your demo-chat, thanks again.
  • The client side has to set the number of channels before it connects to instantiate the needed queues. I assume you do that?

    Our iPhone developer is currently sick at home but I'd like to check what the issue with channels could be.
  • I didn't know that about the client side. Guess thats the problem. I'll look at my xcode to see where to do that.
  • Thanks for the new example! :)
  • I worked some more on documentation for it and extended the demo a little.

    It will be part of the next Unity SDK but you can already find it on this page: ... bychatdemo
  • The chat demo is now part of the Unity Client SDK. It's also life on our developer network:

    The description is now here: ... bychatdemo