-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add and Get Struct is bug #28
Comments
Let me know what is ServerResponse: struct ServerResponse
{
?
} |
sorry for that
|
What is TypeResponse? (enum‽) |
yep
|
Thanks for you help I'll solve this, after I'll give you a feedback. (Nguyen Van Hao) @nvh2001, thanks for your contribution about Byter 💐
|
Fixeduse public struct ServerResponse
{
public TypeResponse typeResponse { get; set; }
public string? message { get; set; }
} This solved your problem? 😄 OptionalYou can use Byter Encoding Extension instead of raw System.Text.Encoding# string to bytes
byte[] @bytes = "Byter".GetBytes(); # global encoding is UTF8
byte[] @bytes = @string.GetBytes(Encoding.UTF32) # use custom encoding
# bytes to string
string @string = [1, 2, 3, 4].GetString(); #global encoding is UTF8
string @string = @bytes.GetString(Encoding.UTF32); #use custom encoding
# update global encoding (UTF8) is default.
StringExtension.Default = Encoding.UTF32; this will allow on future you update encoding easy. Have good feature:
Read more about this feature here: https://github.com/alec1o/Netly?tab=readme-ov-file#for-more-information-and-details-see-byters-official-information |
it's not working (unity & console .NET 8) when using {get; set}
|
I tested in dotnet 8 console application and this (get;set) fixed the problem. Let me test it on unity 6 |
My code, i tested both unity and .net 8
|
Isn't working in .NET 8? |
i download src from github (unity & console .net 8) |
It's working for me on Unity 6 and dotnet 8. using UnityEngine;
using Byter;
using System.Text;
public class Scrip : MonoBehaviour
{
public struct ServerResponse
{
public TypeResponse typeResponse { get; set; }
public string message { get; set; }
}
public enum TypeResponse
{
None,
// Player - Sucess
WebSocketConnectSucces,
GetUserSuccess,
// Player - Error
RemoveSuccess,
NullId,
GetUserError,
SeverMax,
Have2PlayerId,
}
private void Start()
{
// set data
Primitive primitive = new();
var a = new ServerResponse() { typeResponse = TypeResponse.WebSocketConnectSucces, message = "xxx1" };
primitive.Add.Struct(a);
// get data
byte[] buffer = primitive.GetBytes();
var message = Encoding.UTF8.GetString(buffer);
Debug.Log(message);
Debug.Log(message.Length);
}
} |
On your server: (i think you are using console application) # cd myserverpath
dotnet add package byter --version 3.0.0 On your unity
NOTE: |
Thank you, I will try, my project has a short deadline :))) |
Maybe this looks hard, I'll show you how do this.
|
Error when the Struct has a Struct as children. (maybe i think)
|
have same issue when Struct in struct |
I see more. Byter error on WEBGL unity |
ok lemme test it |
You made 2 mistakes:
❤️ Everything is working, just fix the 2 errors mentioned above! 🌹 |
No, that's not it, always use { get; set; } 1000% recommended instead of removing this (as much as it works without { get or set }, I always recommend adding {get; set;}) |
It's work incorrecly, group will be null
|
add {get; set;} to Idol->group |
Severity Code Description Project File Line Suppression State |
Give me 1s |
just slowly comfortable |
It's working! 🤣 🤣 🤣 🤣 Idol idol = new Idol();
idol.name = "Karina";
idol.birthdayYear = 2000;
idol.group = new Group
{
name = "aespa",
birthdayYear = 2019,
};
Primitive send = new Primitive();
send.Add.Struct(idol);
Primitive recive = new Primitive(send.GetBytes());
var reIdol = recive.Get.Struct<Idol>();
Debug.Log(reIdol.name);
Debug.Log(reIdol.birthdayYear);
Debug.Log(reIdol.group.name);
Debug.Log(reIdol.group.birthdayYear); you make a mistake (c# side)
|
It's working now? |
It's woking!!!!!!!! |
Ok, I think this supports Array<Struct|Class|List<Array>> .... Example:
|
Yep it's working with Array and List of struct, so I trying Struc in struct of a struct |
Byter don't have data deep limitation, Make how much complex data it's possible. 🤣 🥳 |
work work!!!!! |
A thing i can reveal for u, dll CAN'T build on Webgl but folder src can do it |
Give me 1s |
I know. you told me before! 🤣 🤣 🤣
Solution
It's working? |
You reminded me C/C++ programmer, always download and unzip library, GLFW, ImGUI, Glad, GLM... 🤣 🤣 🤣 (I love use package manager instead of manual past sources in my projects) 🤣 🤣 |
I try to send struct with byter but error, the data is null. Tks
The text was updated successfully, but these errors were encountered: