Captive Imagination
September 10, 2010, 04:39:12 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: jSeamless 1.0 Beta 7 is Available http://www.jseamless.org
 
   Home   Help Search Calendar Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: about arrays  (Read 1027 times)
0 Members and 1 Guest are viewing this topic.
mrgibson
Newbie
*
Offline Offline

Posts: 9


View Profile
« on: May 24, 2006, 05:12:59 PM »

I created a custom Message containing :

 private String[] players_names;

 public String[] getPlayersNames() {
        return players_names;
    }

When I run it, I receive this warning from java console:
Setter correspondent not found for getPlayersNames, ignoring.

Does JGN support some kind of arrays transmission or I have to serialize everything?

Yanick Bourbeau
MRG Technologies
http://imperium.mrgtech.ca
Logged
liree
Developer
Newbie
*****
Offline Offline

Posts: 27


View Profile
« Reply #1 on: May 25, 2006, 03:27:43 AM »

You need another method:

public void setPlayersNames(String[] names) {
   players_names = names;
}

Each property that shall be transported with JGN must have
a "getter"-Method and a "setter"-Method with equal names (except for get.. and set..).
(The name of the field which actually stores the value may differ)
Logged
mrgibson
Newbie
*
Offline Offline

Posts: 9


View Profile
« Reply #2 on: May 25, 2006, 10:55:23 AM »

This is my message:


package game_server;
import com.captiveimagination.jgn.message.*;

public class AuthReplyMessage extends Message {

    private int player_id;
    private int version;
    private String[] players_names;
    private float[] players_x;
    private float[] players_y;
   
   
   
    public void setPlayerID(int id) {
        player_id = id;
    }
   
    public int getPlayerID() {
        return player_id;
    }

    public void setPlayersNames(String[] names) {
       
        players_names = names;
    }

    public void setPlayersX(float[] x) {
       
        players_x = x;
    }
   
    public void setPlayersY(float[] y) {
       
        players_y = y;
    }
    public String[] getPlayersNames() {
        return players_names;
    }

    public float[] getPlayersX() {
        return players_x;
    }

    public float[] getPlayersY() {
        return players_y;
    }

    public void setVersion(int ver) {
        version = ver;
    }
   
    public int getVersion() {
        return version;
    }

   
}

Now its compile but when I try to sendMessage() this message, I got this:
Object: game_server.ServerNetwork$1@df6ccd, MethodName: messageReceived, Var: game_server.AuthMessage@601bb1, callAll: false
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.captiveimagination.jgn.MessageQueue.callMethod(MessageQueue.java:182)
        at com.captiveimagination.jgn.MessageQueue.sendMessage(MessageQueue.java:147)
        at com.captiveimagination.jgn.MessageQueue.update(MessageQueue.java:100)
        at com.captiveimagination.jgn.MessageServer.updateEvents(MessageServer.java:89)
        at com.captiveimagination.jgn.MessageServer.update(MessageServer.java:73)
        at com.captiveimagination.jgn.MessageServer$1.run(MessageServer.java:46)
Caused by: java.lang.NullPointerException
        at com.captiveimagination.jgn.JGN.get(JGN.java:806)
        at com.captiveimagination.jgn.JGN.convertMessage(JGN.java:547)
        at com.captiveimagination.jgn.UDPMessageServer.resendMessage(UDPMessageServer.java:127)
        at com.captiveimagination.jgn.UDPMessageServer.sendMessage(UDPMessageServer.java:118)
        at game_server.ServerNetwork$1.messageReceived(ServerNetwork.java:105)


Someone have an idea? Smiley

Logged
mrgibson
Newbie
*
Offline Offline

Posts: 9


View Profile
« Reply #3 on: May 25, 2006, 10:57:40 AM »

A extra thing, do Messages can contain Vector or HashMap ?
Logged
darkfrog
Administrator
Inspired Imagination
*****
Offline Offline

Posts: 2650


View Profile
« Reply #4 on: May 25, 2006, 11:34:36 AM »

It looks like it's having a problem with a null value in your object.  Do you have JDT in your classpath?  A lot of the problems associated with null values being passed were addressed better in JDT and not with reflection.  If you still get this problem when you have JDT in your classpath then post how you are instantiating the message and I'll try to reproduce it over here.

darkfrog
Logged
mrgibson
Newbie
*
Offline Offline

Posts: 9


View Profile
« Reply #5 on: May 25, 2006, 12:45:02 PM »

I use redirection right now, I will try with JDT
Logged
darkfrog
Administrator
Inspired Imagination
*****
Offline Offline

Posts: 2650


View Profile
« Reply #6 on: May 25, 2006, 01:24:49 PM »

I hope you mean reflection. :-p

darkfrog
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.197 seconds with 20 queries.