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.
Creating a synchronized slideshow
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Re: Creating a synchronized slideshow
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
}
}
Return to “.Net / Unity3D API”
Who is online
Users browsing this forum: No registered users and 26 guests