add WebSocket endpoint support#66
Open
heshammahamed wants to merge 8 commits into
Open
Conversation
* find all classes annotated with wsEndpoint modifier * validate and extract the four handler functions (onConnect, onReady, onData, onClose) * extract the URI from the modifier params to pass to setWebSocketHandler
* add wsConnection class with isDead flag and guarded send/close methods * implement constructSocketConnectHandler to call user onConnect with raw connection ptr * implement constructSocketReadyHandler to look up wsConnection and call user onReady * implement constructSocketDataHandler with isBinary flag derived from opcode * implement constructSocketCloseHandler to nullify connection, call user onClose, then remove from map * add socketConnections map to track active connections by ptr[Http.Connection]
* Reference handlers by node pointer (Passage), not by name path * Pass the function node to setWebSocketHandler, not its wrapping block * Keep handler blocks alive across insertAst (avoid use-after-free) * Use ArchInt (cast from connection ptr) as the socketConnections key
…f per-class Previously, a single annotated a class containing one method per handler Handlers are now declared individually, each with its own annotation on a standalone function
…g string to ref -- map[String , ptr[TiObject]] -- .
heshammahamed
commented
Jul 7, 2026
| socketUrlHandlers.setAt(hPos, handlersRef(index)~no_deref); | ||
| def element : ptr[Core.Basic.TiObject] = handlersRef(index)~ptr; | ||
|
|
||
| socketUrlHandlers.setAt(hPos, element); |
Contributor
Author
There was a problem hiding this comment.
Map.setAt fails when T2 is a ref[...] type
The bug is in this line inside setAt:
handler this.setAt(i: ArchInt, value: T2): ref[Map[T1, T2]] {
if i < 0 || i >= this.keys.getLength() {
System.fail(1, "Argument `i` is out of range.")
}
this.values(i) = value;
return this
}
this.values(i) returns a ref[T2]. When T2 is itself a ref[...] type, plain = tries to write into whatever that reference currently points to — but if it doesn't point to anything valid yet, this fails/errors, since we need to specify the reference's target before we can assign through it see the Docs about References.
For now i changed my using for Map so instead have T2 as a ref[...] i switch to use ptr[...] data type untill you confirm if it is a real bug and we can see how to solve it.
i think about if we have the T2 is a ref[...] in Map then in the setAt we use ~no_deref operator on the this.value(i) so we make the refrence point to the given value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.