PureMVC in SFS2X

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
jpardoe
Posts: 132
Joined: 31 Aug 2009, 20:54

Postby jpardoe » 04 Nov 2010, 15:23

GameObject.java Used to store certain data including User:

Code: Select all


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.domain.data;

import com.smartfoxserver.v2.entities.User;
import java.util.ArrayList;

/**
 *
 * @author James
 */
public class GameObject {

    private ArrayList _names = new ArrayList();
    private ArrayList _objects = new ArrayList();

    public void GameObject ()
    {
       
    }
    public void putString(String name, String obj)
    {
        _names.add(name);
        _objects.add(obj);
    }

    public void putUser(String name, User obj)
    {
        _names.add(name);
        _objects.add(obj);
    }

    public String getString(String name)
    {
        String retString = null;
       
        if(_names.contains(name))
        {
            retString = (String) _objects.get(_names.indexOf(name));
        }

        return retString;
    }

    public User getUser(String name)
    {
        User retUser = null;

        if(_names.contains(name))
        {
            retUser = (User) _objects.get(_names.indexOf(name));
        }

        return retUser;
    }
}



I look forward to hearing your thoughts so far.
dannyrg
Posts: 19
Joined: 19 Oct 2010, 19:08

Great community work!

Postby dannyrg » 06 Nov 2010, 17:17

Hi JPardoe,

First off, good job. I'm glad to see strong community contributions.

I would like to recommend to the SFS team and to you, JPardoe, if you are so inclined, to perhaps open a specialized PureMVC section for community contributions where code can be posted for download as files/packages (not official or supported by GotoAndPlay, but only community support) and Jpardoe can lead the way.

So you can continue improving this code and people can utilize it to jumpstart things with an ever-increasing quality of code available to use.

It can be a great community open-source addon for SFS2X
(I would recommend doing the same for OpenSpace for SFS2X when it comes out in a few weeks - it can be a part of the same PureMVC section).

Hope this makes sense.

Dan
User avatar
jpardoe
Posts: 132
Joined: 31 Aug 2009, 20:54

Small Improvement

Postby jpardoe » 07 Nov 2010, 09:28

Thanks Dannyrg, I think your suggestion of an independent forum for OpenSource add-ons would be very useful. It will also be beneficial to GotoAndPlay as it will make their product even more useful and accessible.

On a side note:

I have noticed a small improvement that can be carried out by event and request handlers - they no longer have to use handleInternalMessage to send notifications.

Original Code:

Code: Select all

getParentExtension().handleInternalMessage(Notifications.SEND_DATA, user);



Improved Code:

Code: Select all

ServerFacade.getInstance("ServerFacade").sendNotification(Notifications.SEND_DATA, user);



The improved code sends notifications directly by referencing the Facade. This actually means that we no longer need to depend on handleInternalMessage to communicate with the rest of the application.
rshekhar.in
Posts: 2
Joined: 08 Dec 2010, 01:32

Need help

Postby rshekhar.in » 08 Dec 2010, 02:06

I am a novice for PureMVC and SFS. I have already implemented the game logic in SFS2X.

I have followed all your steps to comply my code for PureMVC. However i am still unable to grasp the complete flow in PureMVC.

Can you show me how to catch the login event and authenticate via db the user credentials in PureMVC & SFS2X.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Edithgal, Google [Bot] and 103 guests