enitity.variables .jar
Re: enitity.variables .jar
Thanks for your advice, I realized some things.
Perhaps I am not creating the room correctly, since the created rooms are not displayed in AmindTool, but the game works fine.
If I understand correctly, then my code is sufficient and I don't need to create a variable through my ShooterExtension before using it.
I'll try to debug all the stages as you said and give the result, thanks =)
Perhaps I am not creating the room correctly, since the created rooms are not displayed in AmindTool, but the game works fine.
If I understand correctly, then my code is sufficient and I don't need to create a variable through my ShooterExtension before using it.
I'll try to debug all the stages as you said and give the result, thanks =)
Re: enitity.variables .jar
I did the following work:
1. Created string type room variables for the test, it worked! But it still doesn't work with the object!
2. I created a class that I want to package and inherited from the SerializableSFSType interface, I did the same on the server side using .java code
It still doesn't work, here's my code again:
1.The class that I'm trying to send to the server as an object
2. A method that packs a class into an object and sends it to the server:
3. SERVER code that repeats my class on the client:
Any ideas?
1. Created string type room variables for the test, it worked! But it still doesn't work with the object!
2. I created a class that I want to package and inherited from the SerializableSFSType interface, I did the same on the server side using .java code
It still doesn't work, here's my code again:
1.The class that I'm trying to send to the server as an object
Code: Select all
using Sfs2X.Protocol.Serialization;
using System.Collections.Generic;
namespace sfs2x.extensions.games.shooter.variable
{
public class ItemRoomInfo : SerializableSFSType
{
public List<float> ItemPosition = new List<float>();
public string ItemType;
public int ItemIndex;
}
}2. A method that packs a class into an object and sends it to the server:
Code: Select all
private void SaveItemInRoom(ItemRoomInfo info)
{
Room room = _sfs.LastJoinedRoom;
SFSObject itemData = new SFSObject();
itemData.PutClass("item", info);
SFSRoomVariable roomVariable = new SFSRoomVariable("item_" + info.ItemIndex, itemData);
roomVariable.IsPersistent = true;
List<RoomVariable> roomVars = new List<RoomVariable> { roomVariable };
_sfs.Send(new SetRoomVariablesRequest(roomVars, room));
}3. SERVER code that repeats my class on the client:
Code: Select all
package sfs2x.extensions.games.shooter.variable;
import com.smartfoxserver.v2.protocol.serialization.SerializableSFSType;
import java.util.List;
public class ItemRoomInfo implements SerializableSFSType
{
public List<Float> ItemPosition;
public String ItemType;
public int ItemIndex;
public ItemRoomInfo(List<Float> ItemPosition, String ItemType, int ItemIndex)
{
this.ItemPosition = ItemPosition;
this.ItemType = ItemType;
this.ItemIndex = ItemIndex;
}
}Any ideas?
Re: enitity.variables .jar
Hi,
is there any error regarding serialization either on the client or server side? Without errors it's unlikely that this (the custom class) is the cause of your problem.
Thanks
is there any error regarding serialization either on the client or server side? Without errors it's unlikely that this (the custom class) is the cause of your problem.
Thanks
Re: enitity.variables .jar
I'm not sure about the errors, because I don't know how to catch them on the server side.
If I understand correctly, something should be displayed in the Log section of AdminTools, but it’s empty.
There are no errors on the client, since it works with other variables and does not work only with my class, I tried to do everything according to the documentation
The logs on the client also don’t show anything bad.
If I understand correctly, something should be displayed in the Log section of AdminTools, but it’s empty.
There are no errors on the client, since it works with other variables and does not work only with my class, I tried to do everything according to the documentation
The logs on the client also don’t show anything bad.
Re: enitity.variables .jar
Here are the reasons because I want to do it this way and not otherwise:
1. Why am I so keen on creating variables dynamically? Because I may have a different number of items that need to be saved
2. Why a custom class object? Because I also plan to show the destructibility of buildings on the map and I need to preserve their state, position,
maybe there’s something else and you don’t want to clog up the server with unnecessary stuff.
For these reasons I'm trying to get the hang of saving custom classes on the server side
Another reason is that I want to learn how to do this and make lessons on how to use it on YouTube, since I haven’t found it and I want to offer your service for use at work, because I like it more than any other
1. Why am I so keen on creating variables dynamically? Because I may have a different number of items that need to be saved
2. Why a custom class object? Because I also plan to show the destructibility of buildings on the map and I need to preserve their state, position,
maybe there’s something else and you don’t want to clog up the server with unnecessary stuff.
For these reasons I'm trying to get the hang of saving custom classes on the server side
Another reason is that I want to learn how to do this and make lessons on how to use it on YouTube, since I haven’t found it and I want to offer your service for use at work, because I like it more than any other
Re: enitity.variables .jar
If the Log Viewer module of the AdminTool is empty, something is wrong. You should always see something (did you click the Load button?). In any case you can also check the logs directly, in the /logs folder.
If nothing shows up in the logs, I'd suggest to create a very simple project showing how to reproduce the issue, and send it to our support team.
If nothing shows up in the logs, I'd suggest to create a very simple project showing how to reproduce the issue, and send it to our support team.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Re: enitity.variables .jar
DarkGon wrote:I'm not sure about the errors, because I don't know how to catch them on the server side.
No problem. Actually if you don't catch them they will show up in the server logs. If you don't have any errors I don't think there's a problem with your custom classes.
Usually, if there's a problem you would notice very quickly because you'd see a serialization error (on the client or server, depending which side is sending).
If I understand correctly, something should be displayed in the Log section of AdminTools, but it’s empty.
You also said you're not able to find the Rooms you create in the AdminTool. That's not possible, all the Rooms are shown there, no one escapes
If you don't specify one they will be created in the default Group (called unsurprisingly 'default').
Please, give it another look and when you find the Room check the list of Room Variables and let us know if they exist, as we'd expect.
Thanks
Re: enitity.variables .jar
Hello, I feel very stupid because the rooms in AminTools were not displayed due to the fact that I did not notice that there was a filter for displaying rooms, I set the filter to "any" and saw the rooms, I also saw that any variables were displayed except mine objects.
I'm almost sure that I'm not serializing the custom class correctly on the server side.
That's what I'm doing:
1. Create a class ItemInRoom on the client that inherits from SerializableSFSType and set variables like List<float>, int, string
2. In the same class I create a constructor that receives data from above
3. I set the namespace to be the same as on the server side
On the server side:
1.
I create a class ItemInRoom and inherit from SerializableSFSType and set variables of type Array<Float>, int, string
2. In the same class I create a constructor that receives data from above
3. I set the package to be the same as on the client
Once I caught in the logs: Class not found on the server side,
after that I entered import and the path to the custom class in ShooterExtension, now there are no errors in the logs, but the object does not seem to be serialized
I'm almost sure that I'm not serializing the custom class correctly on the server side.
That's what I'm doing:
1. Create a class ItemInRoom on the client that inherits from SerializableSFSType and set variables like List<float>, int, string
2. In the same class I create a constructor that receives data from above
3. I set the namespace to be the same as on the server side
On the server side:
1.
I create a class ItemInRoom and inherit from SerializableSFSType and set variables of type Array<Float>, int, string
2. In the same class I create a constructor that receives data from above
3. I set the package to be the same as on the client
Once I caught in the logs: Class not found on the server side,
after that I entered import and the path to the custom class in ShooterExtension, now there are no errors in the logs, but the object does not seem to be serialized
- Attachments
-
- SFS2X_RuntimeLog_backup_20240703_133051.zip
- (8.93 KiB) Downloaded 143 times
Re: enitity.variables .jar
In your logs there's very high occurrence of extension errors, like this:
This means that the jar file you're deploying does not contain the class referenced above. I would recommend to check the export process in your Java IDE and make sure that all your classes are included in the exported jar.
Once this is fixed we can check the other issue with serialization.
I am not sure what you mean in the bolded part of the statement.
Cheers
Code: Select all
Exception: com.smartfoxserver.v2.exceptions.SFSExtensionException
Message: Class not found: sfs2x.extensions.games.shooter.ShooterExtension
This means that the jar file you're deploying does not contain the class referenced above. I would recommend to check the export process in your Java IDE and make sure that all your classes are included in the exported jar.
Once this is fixed we can check the other issue with serialization.
Once I caught in the logs: Class not found on the server side,
after that I entered import and the path to the custom class in ShooterExtension, now there are no errors in the logs, but the object does not seem to be serialized
I am not sure what you mean in the bolded part of the statement.
Cheers