smartfoxserver 2x 数据共享问题

1.静态类,发觉不能共享数据,,简单的解决方法是,复制多一份扩展到 \extensions\__lib__\ 目录。。。不过不推荐这样做,因为你每改一次,都要复制一次

2.客户端发送请求时,不要指定房间,请看CODE

        //smartFox.Send(new ExtensionRequest("mmove", moveObj, smartFox.LastJoinedRoom));

        smartFox.Send(new ExtensionRequest("move", moveObj));

折腾了很久搞定。。。。

不过第二种我没试过用静态数组来保存,,如果你测试成功留个言吧,

第二种我是在主MAIN 扩展里加个变量,模仿官方的写法的。。共享的,如果你用静态变量来保存不行的话,可以试试这样。

    private World world;

    public World getWorld()

    {

        return world;

    }

    public void init() {

        //trace("\n++++++++++++++++++++init+++++++++++++++++++++\n");

        // login -> zonejoin -> ext init

        // destroy -> remove join room ->  DISCONNECT

        world=new World(this);

        addEventHandler(SFSEventType.USER_LOGIN, LoginHandler.class); 

        addEventHandler(SFSEventType.USER_JOIN_ZONE, ZoneJoinEventHandler.class);

        addEventHandler(SFSEventType.USER_LOGOUT, LogoutHandler.class); 

        addEventHandler(SFSEventType.USER_DISCONNECT, LogoutHandler.class); 

        //addEventHandler(SFSEventType.USER_JOIN_ROOM, JoinRoomHandler.class);

        //initMysql();

        

        //addRequestHandler("createPlayer", CreatePlayerRequestHandler.class);

        addRequestHandler("attack", AttackRequestHandler.class); 

        addRequestHandler("move", MoveRequestHandler.class);



    }

你可能感兴趣的:(server)