Page 1 of 1

Creating a synchronized slideshow

Posted: 29 Nov 2010, 21:00
by zante
I'm using the Unity networking engine to handle a few functions as part of my multi-user environment.

One of them is a slideshow. It's a plane with two more to the left and right of it acting as "previous" and "next" buttons. Outside of Smartfox, I have this set up working perfectly. When a client connects, the server updates all connections with the current slide number to make sure everyone sees the same thing. Similarly, when a client clicks the next button, an RPC is sent to the server to increment the current slide number which then updates all clients.

What is the correct way to go about doing this inside smartfox, what conventions do I need to adhere to in order to make this work?

Is there a way to detect when a user connects? Would I script this from inside Unity - it seems unlikely. It makes sense that I'd have to write an external script for the server to process.

Feedback is appreciated.

Re: Creating a synchronized slideshow

Posted: 30 Nov 2010, 11:16
by ThomasLund
zante wrote:What is the correct way to go about doing this inside smartfox, what conventions do I need to adhere to in order to make this work?


Dont know if there are actual conventions per se.

Sending an extension request with new slide number is simply done to the extension, which then sends the slide number to all users in the room.

So very simple and not many lines of code.

zante wrote:Is there a way to detect when a user connects? Would I script this from inside Unity - it seems unlikely. It makes sense that I'd have to write an external script for the server to process.
Feedback is appreciated.


Depends slightly on what version server you run, but the code should definitely be on the server - which then e.g. initializes your slideshow for that client and sends the current slide number to him.

2x you do something like this in the main extension code:

Code: Select all

      addEventHandler(SFSEventType.USER_JOIN_ROOM, OnServerStatusChangedHandler.class);


And then you have a the class to do "something" with the info

Code: Select all

public class OnServerStatusChangedHandler extends BaseServerEventHandler {

   @Override
   public void handleServerEvent(ISFSEvent event) throws SFSException {
      // DO SOMETHING
   }
}