Skip to content
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

1.0.0: Planned changes #75

Closed
endel opened this issue May 30, 2020 · 13 comments
Closed

1.0.0: Planned changes #75

endel opened this issue May 30, 2020 · 13 comments
Assignees
Milestone

Comments

@endel
Copy link
Member

endel commented May 30, 2020

Hi guys, I've been tinkering on the changes necessary to improve the overall usage of @colyseus/schema (a.k.a. state serializer) and here's the list of open issues I'm planning to close on the 1.0.0 update:

This is going to require restructuring and rewriting some parts of the encoder and decoder across all languages, the plan is to be able to release it next month.

Another big change is the client-side callbacks. They are currently triggered one by one, before the full patch is applied on the client's state. It would be better if the callbacks are triggered after the client received and updated its local state.

If you have any suggestions or feedback to give regarding how the @colyseus/schema works, or could work differently - this is the right moment. Decisions made during next month will live probably for the next year or so.

Thanks!

@endel endel self-assigned this May 30, 2020
@endel endel added this to the 0.6.0 milestone May 30, 2020
@endel endel changed the title 0.6.0: Planned changes 1.0.0: Planned changes May 30, 2020
endel added a commit that referenced this issue Jun 3, 2020
endel added a commit that referenced this issue Jun 4, 2020
endel added a commit that referenced this issue Jun 5, 2020
endel added a commit that referenced this issue Jun 7, 2020
endel added a commit that referenced this issue Jun 8, 2020
endel added a commit that referenced this issue Jun 9, 2020
@dclipca
Copy link

dclipca commented Jun 11, 2020

@endel, one thing with a high value and relatively low development effort would be directly supporting objects in the Schema without having to store them serialized.

@endel
Copy link
Member Author

endel commented Jun 11, 2020

Hi @virtumonde, not sure if I understand what do you mean, you mind providing an example of how this could look like?

@dclipca
Copy link

dclipca commented Jun 11, 2020

@endel, that was not a very good description. What I mean is being able to store objects in the Schema. As of now, the only way I was able to do so is by using JSON.stringify() and then retrieving using JSON.parse(). I know that you can store instances of classes provided that you specify what class is the given instance but I didn't find ways to store objects directly without any dancing around the serialization.

@dclipca
Copy link

dclipca commented Jun 11, 2020

If I am right and there is no way to directly introduce untyped objects (not class instances) into Schema without JSON.stringify() then it would be extremely helpful if Colyseus would do the JSON.stringify()/JSON.parse() thing automatically somehow (I think this makes sense to do from the side of the client).

@Zielak
Copy link
Contributor

Zielak commented Jun 11, 2020

From what I gather, serializing exists to compress your objects, so less bytes are transferred. Just doing JSON.stringify() on one end means you're transferring everything "uncompressed" as a huge string.
Whats your use case? Why do you want to store whole object literal directly, without serialization? Maybe there's another way of solving the problem for you.

Edit: also, with serialization Colyseus is able to tell which exact properties changed and send an update only for that single property (less bytes to send!). With non-serialized object, there's no way of precisely telling which part of it changed and when, so I imagine we would need to dump that whole object down the pipe.

@endel
Copy link
Member Author

endel commented Jun 11, 2020

I was going to say exactly what @Zielak mentioned. The major problem would be detecting changes inside an untyped structure, and adding more dependencies to the decoder.

The built-in JSON decoder from Unity is quite limited, and wouldn't support decoding without having some extra types in the client-side for the particular structure. Msgpack could be used for this instead of JSON - but this would make the decoder coupled to a dependency, right now the @colyseus/schema has zero dependencies, which makes it easier to maintain. I'd prefer not adding any extra dependency here.

@dclipca
Copy link

dclipca commented Jun 13, 2020

What I need is storing objects in the state in a way that is compatible with serialization, then. I cannot do this with a Map because the Shema accepts only one type, I cannot use the type | type | type syntax as in Typescript.

endel added a commit that referenced this issue Jul 8, 2020
endel added a commit that referenced this issue Jul 9, 2020
endel added a commit that referenced this issue Jul 9, 2020
endel added a commit to colyseus/colyseus.js that referenced this issue Jul 9, 2020
endel added a commit that referenced this issue Jul 10, 2020
@endel endel mentioned this issue Jul 11, 2020
1 task
endel added a commit to colyseus/docs that referenced this issue Jul 13, 2020
endel added a commit that referenced this issue Jul 13, 2020
endel added a commit that referenced this issue Jul 17, 2020
endel added a commit that referenced this issue Jul 20, 2020
@endel endel unpinned this issue Oct 1, 2020
@endel endel closed this as completed Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants